
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>bent_plume_model &#8212; Texas A&amp;M Oil spill / Outfall Calculator 2.1.0 documentation</title>
    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
   
  <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <h1>Source code for bent_plume_model</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Bent Plume Model</span>
<span class="sd">================</span>

<span class="sd">Simulate a buoyant plume in crossflowing ambient conditions</span>

<span class="sd">This module defines the classes, methods, and functions necessary to simulate</span>
<span class="sd">the buoyant plume behavior in crossflowing ambient conditions, where the</span>
<span class="sd">intrusion layer is not expected to interact with the rising stage of the</span>
<span class="sd">plume. The ambient water properties are provided through an `ambient.Profile`</span>
<span class="sd">class object, which contains a netCDF4-classic dataset of CTD data and the</span>
<span class="sd">needed interpolation methods. The `dbm` class objects `dbm.FluidParticle` and</span>
<span class="sd">`dbm.InsolubleParticle` report the properties of the dispersed phase during</span>
<span class="sd">the simulation, and these methods are provided to the model through the</span>
<span class="sd">objects defined in `dispersed_phases`.</span>

<span class="sd">This module manages the setup, simulation, and post-processing for the model.</span>
<span class="sd">The numerical solution is contained in the `lpm` module.</span>

<span class="sd">Notes</span>
<span class="sd">-----</span>
<span class="sd">This model is a Lagrangian plume integral model following the approach in</span>
<span class="sd">Lee and Cheung (1990) for single-phase plumes, updated using the shear</span>
<span class="sd">entrainment formulation in Jirka (2004), and adapted to multiphase plumes</span>
<span class="sd">following the methods of Johansen (2000, 2003) and Zheng and Yapa (1997).</span>
<span class="sd">Several modifications are made to make the model consistent with the approach</span>
<span class="sd">in Socolofsky et al. (2008) and to match the available validation data.</span>

<span class="sd">The model can run as a single-phase or multi-phase plume.  A single-phase</span>
<span class="sd">plume simply has an empty `particles` list.</span>

<span class="sd">See Also</span>
<span class="sd">--------</span>
<span class="sd">`stratified_plume_model` : Predicts the plume solution for quiescent ambient</span>
<span class="sd">    conditions or weak crossflows, where the intrusion (outer plume)</span>
<span class="sd">    interacts with the upward rising plume in a double-plume integral model</span>
<span class="sd">    approach.  Such a situation is handeled properly in the</span>
<span class="sd">    `stratified_plume_model` and would violate the assumption of non-</span>
<span class="sd">    iteracting Lagrangian plume elements as required in this module.</span>

<span class="sd">`single_bubble_model` : Tracks the trajectory of a single bubble, drop or</span>
<span class="sd">    particle through the water column.  The numerical solution used here,</span>
<span class="sd">    including the various object types and their functionality, follows the</span>
<span class="sd">    pattern in the `single_bubble_model`.  The main difference is the more</span>
<span class="sd">    complex state space and governing equations.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="c1"># S. Socolofsky, November 2014, Texas A&amp;M University &lt;socolofs@tamu.edu&gt;.</span>

<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="p">(</span><span class="n">absolute_import</span><span class="p">,</span> <span class="n">division</span><span class="p">,</span> <span class="n">print_function</span><span class="p">)</span>

<span class="kn">from</span> <span class="nn">tamoc</span> <span class="kn">import</span> <span class="n">model_share</span>
<span class="kn">from</span> <span class="nn">tamoc</span> <span class="kn">import</span> <span class="n">ambient</span>
<span class="kn">from</span> <span class="nn">tamoc</span> <span class="kn">import</span> <span class="n">seawater</span>
<span class="kn">from</span> <span class="nn">tamoc</span> <span class="kn">import</span> <span class="n">single_bubble_model</span>
<span class="kn">from</span> <span class="nn">tamoc</span> <span class="kn">import</span> <span class="n">dispersed_phases</span>
<span class="kn">from</span> <span class="nn">tamoc</span> <span class="kn">import</span> <span class="n">lmp</span>

<span class="kn">from</span> <span class="nn">netCDF4</span> <span class="kn">import</span> <span class="n">Dataset</span>
<span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">datetime</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">from</span> <span class="nn">numpy.linalg</span> <span class="kn">import</span> <span class="n">inv</span>
<span class="kn">from</span> <span class="nn">scipy.optimize</span> <span class="kn">import</span> <span class="n">fsolve</span>
<span class="c1"># import matplotlib as mpl</span>
<span class="c1"># import matplotlib.pyplot as plt</span>

<span class="c1"># ----------------------------------------------------------------------------</span>
<span class="c1"># Main Model object</span>
<span class="c1"># ----------------------------------------------------------------------------</span>

<div class="viewcode-block" id="Model"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.Model.html#bent_plume_model.Model">[docs]</a><span class="k">class</span> <span class="nc">Model</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Master class object for controlling and post-processing the simulation</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    profile : `ambient.Profile` object, default = None</span>
<span class="sd">        An object containing the ambient CTD data and associated methods.</span>
<span class="sd">        The netCDF dataset stored in the `ambient.Profile` object may be open</span>
<span class="sd">        or closed at instantiation.  If open, the initializer will close the</span>
<span class="sd">        file since this model does not support changing the ambient data once</span>
<span class="sd">        initialized.</span>
<span class="sd">    simfile: str, default = None</span>
<span class="sd">        File name of a netCDF file containing the results of a previous</span>
<span class="sd">        simulation run.</span>

<span class="sd">    Attributes</span>
<span class="sd">    ----------</span>
<span class="sd">    profile : `ambient.Profile`</span>
<span class="sd">        Ambient CTD data</span>
<span class="sd">    got_profile : bool</span>
<span class="sd">        Flag indicating whether or not the profile object was successfully</span>
<span class="sd">        loaded into the `Model` object memory</span>
<span class="sd">    p : `ModelParams`</span>
<span class="sd">        Container for the fixed model parameters</span>
<span class="sd">    sim_stored : bool</span>
<span class="sd">        Flag indicating whether or not a simulation result is stored in the</span>
<span class="sd">        object memory</span>
<span class="sd">    X : ndarray</span>
<span class="sd">        Release location (x, y, z) in (m)</span>
<span class="sd">    D : float</span>
<span class="sd">        Diameter for the equivalent circular cross-section of the release (m)</span>
<span class="sd">    Vj : float</span>
<span class="sd">        Scalar value of the magnitude of the discharge velocity for continuous</span>
<span class="sd">        phase fluid in the discharge.  This variable should be 0. or None for</span>
<span class="sd">        a pure multiphase discharge.</span>
<span class="sd">    phi_0 : float</span>
<span class="sd">        Vertical angle from the horizontal for the discharge orientation</span>
<span class="sd">        (rad in range +/- pi/2)</span>
<span class="sd">    theta_0 : float</span>
<span class="sd">        Horizontal angle from the x-axis for the discharge orientation.  The</span>
<span class="sd">        x-axis is taken in the direction of the ambient current.  (rad in</span>
<span class="sd">        range 0 to 2 pi)</span>
<span class="sd">    Sj : float</span>
<span class="sd">        Salinity of the continuous phase fluid in the discharge (psu)</span>
<span class="sd">    Tj : float</span>
<span class="sd">        Temperature of the continuous phase fluid in the discharge (K)</span>
<span class="sd">    cj : ndarray</span>
<span class="sd">        Concentration of passive tracers in the discharge (user-defined)</span>
<span class="sd">    tracers : string list</span>
<span class="sd">        List of passive tracers in the discharge.  These can be chemicals</span>
<span class="sd">        present in the ambient `profile` data, and if so, entrainment of these</span>
<span class="sd">        chemicals will change the concentrations computed for these tracers.</span>
<span class="sd">        However, none of these concentrations are used in the dissolution of</span>
<span class="sd">        the dispersed phase.  Hence, `tracers` should not contain any</span>
<span class="sd">        chemicals present in the dispersed phase particles.</span>
<span class="sd">    particles : list of `Particle` objects</span>
<span class="sd">        List of `Particle` objects describing each dispersed phase in the</span>
<span class="sd">        simulation</span>
<span class="sd">    track : bool</span>
<span class="sd">        Flag indicating whether or not to track the particle through</span>
<span class="sd">        the water column using the `single_bubble_model`.</span>
<span class="sd">    dt_max : float</span>
<span class="sd">        Maximum step size to take in the storage of the simulation solution</span>
<span class="sd">        (s)</span>
<span class="sd">    sd_max : float</span>
<span class="sd">        Maximum number of orifice diameters to compute the solution along</span>
<span class="sd">        the plume centerline (m/m)</span>
<span class="sd">    K_T0 : ndarray</span>
<span class="sd">        Array of heat transfer reduction factors for the particle objects</span>
<span class="sd">        which is used to restart heat transfer after the simulation ends</span>
<span class="sd">        since during simulation, heat transfer is turned off.</span>
<span class="sd">    chem_names : string list</span>
<span class="sd">        List of chemical parameters to track for the dissolution.  Only the</span>
<span class="sd">        parameters in this list will be used to set background concentration</span>
<span class="sd">        for the dissolution, and the concentrations of these parameters are</span>
<span class="sd">        computed separately from those listed in `tracers` or inputed from</span>
<span class="sd">        the discharge through `cj`.</span>
<span class="sd">    q_local : `LagElement` object</span>
<span class="sd">        Object that translates the `Model` state space `t` and `q` into the</span>
<span class="sd">        comprehensive list of derived variables.</span>
<span class="sd">    t : ndarray</span>
<span class="sd">        Array of times computed in the solution (s)</span>
<span class="sd">    q : ndarray</span>
<span class="sd">        Array of state space values computed in the solution</span>

<span class="sd">    See Also</span>
<span class="sd">    --------</span>
<span class="sd">    simulate, save_sim, save_txt, load_sim, plot_state_space,</span>
<span class="sd">    plot_all_variables</span>

<span class="sd">    &quot;&quot;&quot;</span>
<div class="viewcode-block" id="Model.__init__"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.Model.html#bent_plume_model.Model.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">profile</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">simfile</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">Model</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>

        <span class="k">if</span> <span class="n">profile</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="c1"># Create a Model object from a save file</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">load_sim</span><span class="p">(</span><span class="n">simfile</span><span class="p">)</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="c1"># Create a new Model object</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">profile</span> <span class="o">=</span> <span class="n">profile</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">got_profile</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="n">profile</span><span class="o">.</span><span class="n">close_nc</span><span class="p">()</span>

            <span class="c1"># Set the model parameters that the user cannot adjust</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">p</span> <span class="o">=</span> <span class="n">ModelParams</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">)</span>

            <span class="c1"># Indicate that the simulation has not yet been conducted</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="o">=</span> <span class="kc">False</span></div>

<div class="viewcode-block" id="Model.simulate"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.Model.simulate.html#bent_plume_model.Model.simulate">[docs]</a>    <span class="k">def</span> <span class="nf">simulate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">D</span><span class="p">,</span> <span class="n">Vj</span><span class="p">,</span> <span class="n">phi_0</span><span class="p">,</span> <span class="n">theta_0</span><span class="p">,</span> <span class="n">Sj</span><span class="p">,</span> <span class="n">Tj</span><span class="p">,</span> <span class="n">cj</span><span class="p">,</span> <span class="n">tracers</span><span class="p">,</span>
                 <span class="n">particles</span><span class="o">=</span><span class="p">[],</span> <span class="n">track</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">dt_max</span><span class="o">=</span><span class="mf">60.</span><span class="p">,</span> <span class="n">sd_max</span><span class="o">=</span><span class="mf">350.</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Simulate the plume dynamics from given initial conditions</span>

<span class="sd">        Simulate the buoyant plume using a Lagrangian plume integral model</span>
<span class="sd">        approach until the plume reaches the surface, the integration</span>
<span class="sd">        exceeds the given s/D (`sd_max`), or the intrusion reaches a point of</span>
<span class="sd">        neutral buoyancy.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        X : ndarray</span>
<span class="sd">            Release location (x, y, z) in (m)</span>
<span class="sd">        D : float</span>
<span class="sd">            Diameter for the equivalent circular cross-section of the release</span>
<span class="sd">            (m)</span>
<span class="sd">        Vj : float</span>
<span class="sd">            Scalar value of the magnitude of the discharge velocity for</span>
<span class="sd">            continuous phase fluid in the discharge.  This variable should be</span>
<span class="sd">            0. or None for a pure multiphase discharge.</span>
<span class="sd">        phi_0 : float</span>
<span class="sd">            Vertical angle from the horizontal for the discharge orientation</span>
<span class="sd">            (rad in range +/- pi/2)</span>
<span class="sd">        theta_0 : float</span>
<span class="sd">            Horizontal angle from the x-axis for the discharge orientation.</span>
<span class="sd">            The x-axis is taken in the direction of the ambient current.</span>
<span class="sd">            (rad in range 0 to 2 pi)</span>
<span class="sd">        Sj : float</span>
<span class="sd">            Salinity of the continuous phase fluid in the discharge (psu)</span>
<span class="sd">        Tj : float</span>
<span class="sd">            Temperature of the continuous phase fluid in the discharge (T)</span>
<span class="sd">        cj : ndarray</span>
<span class="sd">            Concentration of passive tracers in the discharge (user-defined)</span>
<span class="sd">        tracers : string list</span>
<span class="sd">            List of passive tracers in the discharge.  These can be chemicals</span>
<span class="sd">            present in the ambient `profile` data, and if so, entrainment of</span>
<span class="sd">            these chemicals will change the concentrations computed for these</span>
<span class="sd">            tracers.  However, none of these concentrations are used in the</span>
<span class="sd">            dissolution of the dispersed phase.  Hence, `tracers` should not</span>
<span class="sd">            contain any chemicals present in the dispersed phase particles.</span>
<span class="sd">        particles : list of `Particle` objects</span>
<span class="sd">            List of `Particle` objects describing each dispersed phase in the</span>
<span class="sd">            simulation</span>
<span class="sd">        track : bool</span>
<span class="sd">            Flag indicating whether or not to track the particle through</span>
<span class="sd">            the water column using the `single_bubble_model`.</span>
<span class="sd">        dt_max : float</span>
<span class="sd">            Maximum step size to take in the storage of the simulation</span>
<span class="sd">            solution (s)</span>
<span class="sd">        sd_max : float</span>
<span class="sd">            Maximum number of orifice diameters to compute the solution along</span>
<span class="sd">            the plume centerline (m/m)</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Make sure the position is an array</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">):</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">X</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
                <span class="c1"># Assume user specified the depth only</span>
                <span class="n">X</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mf">0.</span><span class="p">,</span> <span class="mf">0.</span><span class="p">,</span> <span class="n">X</span><span class="p">])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">X</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">X</span><span class="p">)</span>

        <span class="c1"># Make sure the tracer data are in an array</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">cj</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">):</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">cj</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
                <span class="n">cj</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">cj</span><span class="p">])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">cj</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">cj</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">tracers</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
            <span class="n">tracers</span> <span class="o">=</span> <span class="p">[</span><span class="n">tracers</span><span class="p">]</span>

        <span class="c1"># Store the input parameters</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">X</span> <span class="o">=</span> <span class="n">X</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">D</span> <span class="o">=</span> <span class="n">D</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Vj</span> <span class="o">=</span> <span class="n">Vj</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">phi_0</span> <span class="o">=</span> <span class="n">phi_0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">theta_0</span> <span class="o">=</span> <span class="n">theta_0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Sj</span> <span class="o">=</span> <span class="n">Sj</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span> <span class="o">=</span> <span class="n">Tj</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cj</span> <span class="o">=</span> <span class="n">cj</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">tracers</span> <span class="o">=</span> <span class="n">tracers</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">particles</span> <span class="o">=</span> <span class="n">particles</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">track</span> <span class="o">=</span> <span class="n">track</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dt_max</span> <span class="o">=</span> <span class="n">dt_max</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sd_max</span> <span class="o">=</span> <span class="n">sd_max</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">K_T0</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">K_T</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span>
                              <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">))])</span>

        <span class="c1"># Create the initial state space from the given input variables</span>
        <span class="n">t0</span><span class="p">,</span> <span class="n">q0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">chem_names</span> <span class="o">=</span> <span class="n">lmp</span><span class="o">.</span><span class="n">main_ic</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">,</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">D</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Vj</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">phi_0</span><span class="p">,</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">theta_0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Sj</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">cj</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">tracers</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">p</span><span class="p">)</span>

        <span class="c1"># Store the initial conditions in a Lagrangian element object</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">q_local</span> <span class="o">=</span> <span class="n">LagElement</span><span class="p">(</span><span class="n">t0</span><span class="p">,</span> <span class="n">q0</span><span class="p">,</span> <span class="n">D</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">p</span><span class="p">,</span>
                       <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">tracers</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">chem_names</span><span class="p">)</span>

        <span class="c1"># Compute the buoyant jet trajectory</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">-- TEXAS A&amp;M OIL-SPILL CALCULATOR (TAMOC) --&#39;</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;-- Bent Plume Model                       --</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">t</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">q</span><span class="p">,</span> <span class="o">=</span> <span class="n">lmp</span><span class="o">.</span><span class="n">calculate</span><span class="p">(</span><span class="n">t0</span><span class="p">,</span> <span class="n">q0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">q_local</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">,</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">p</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">,</span> <span class="n">lmp</span><span class="o">.</span><span class="n">derivs</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">dt_max</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sd_max</span><span class="p">)</span>

        <span class="c1"># Track the particles</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">track</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">)):</span>
                <span class="k">if</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">integrate</span> <span class="ow">is</span> <span class="kc">False</span> <span class="ow">and</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">z</span> <span class="o">&gt;</span> <span class="mf">0.</span><span class="p">:</span>
                    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">Tracking Particle </span><span class="si">%d</span><span class="s1"> of </span><span class="si">%d</span><span class="s1">:&#39;</span> <span class="o">%</span>
                        <span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">)))</span>
                    <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">run_sbm</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">)</span>

        <span class="c1"># Update the status of the solution</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="o">=</span> <span class="kc">True</span>

        <span class="c1"># Update the status of the particles</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">)):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">sim_stored</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">K_T</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">K_T0</span><span class="p">[</span><span class="n">i</span><span class="p">]</span></div>

<div class="viewcode-block" id="Model.save_sim"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.Model.save_sim.html#bent_plume_model.Model.save_sim">[docs]</a>    <span class="k">def</span> <span class="nf">save_sim</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fname</span><span class="p">,</span> <span class="n">profile_path</span><span class="p">,</span> <span class="n">profile_info</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Save the current simulation results</span>

<span class="sd">        Save the current simulation results and the model parameters so that</span>
<span class="sd">        all information needed to rebuild the class object is stored in a</span>
<span class="sd">        file.  The output data are stored in netCDF4-classic format.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fname : str</span>
<span class="sd">            File name of the netCDF file to write</span>
<span class="sd">        profile_path : str</span>
<span class="sd">            String stating the file path to the ambient profile data relative</span>
<span class="sd">            to the directory where `fname` will be saved.</span>
<span class="sd">        profile_info : str</span>
<span class="sd">            Single line of text describing the ambient profile data.</span>

<span class="sd">        See Also</span>
<span class="sd">        --------</span>
<span class="sd">        dispersed_phases.save_particle_to_nc_file</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        It does not make sense to store the ambient data together with every</span>
<span class="sd">        simulation output file.  On the other hand, the simulation results</span>
<span class="sd">        may be meaningless without the context of the ambient data.  The</span>
<span class="sd">        parameter `profile_path` provides a means to automatically load the</span>
<span class="sd">        ambient data assuming the profile data are kept in the same place</span>
<span class="sd">        relative to the output file.  Since this cannot be guaranteed, the</span>
<span class="sd">        `profile_info` variable provides additional descriptive information</span>
<span class="sd">        so that the ambient data can be identified if they have been moved.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;No simulation results to store...&#39;</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Saved nothing to netCDF file.</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
            <span class="k">return</span>

        <span class="c1"># Create the netCDF dataset object</span>
        <span class="n">title</span> <span class="o">=</span> <span class="s1">&#39;Simulation results for the TAMOC Bent Plume Model&#39;</span>
        <span class="n">nc</span> <span class="o">=</span> <span class="n">model_share</span><span class="o">.</span><span class="n">tamoc_nc_file</span><span class="p">(</span><span class="n">fname</span><span class="p">,</span> <span class="n">title</span><span class="p">,</span> <span class="n">profile_path</span><span class="p">,</span>
            <span class="n">profile_info</span><span class="p">)</span>

        <span class="c1"># Create variables for the dimensions</span>
        <span class="n">t</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">&#39;t&#39;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
        <span class="n">p</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">&#39;profile&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
        <span class="n">ns</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">&#39;ns&#39;</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">q_local</span><span class="o">.</span><span class="n">q0</span><span class="p">))</span>
        <span class="n">params</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createDimension</span><span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>

        <span class="c1"># Save the names of the chemicals in the tracers and particle objects</span>
        <span class="n">nc</span><span class="o">.</span><span class="n">tracers</span> <span class="o">=</span> <span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tracers</span><span class="p">)</span>
        <span class="n">nc</span><span class="o">.</span><span class="n">chem_names</span> <span class="o">=</span> <span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">chem_names</span><span class="p">)</span>

        <span class="c1"># Create variables to store the initial conditions</span>
        <span class="n">x0</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;x0&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,))</span>
        <span class="n">x0</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;Initial value of the x-coordinate&#39;</span>
        <span class="n">x0</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;x0&#39;</span>
        <span class="n">x0</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;m&#39;</span>

        <span class="n">y0</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;y0&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,))</span>
        <span class="n">y0</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;Initial value of the y-coordinate&#39;</span>
        <span class="n">y0</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;y0&#39;</span>
        <span class="n">y0</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;m&#39;</span>

        <span class="n">z0</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;z0&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,))</span>
        <span class="n">z0</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;Initial depth below the water surface&#39;</span>
        <span class="n">z0</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;depth&#39;</span>
        <span class="n">z0</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;m&#39;</span>
        <span class="n">z0</span><span class="o">.</span><span class="n">axis</span> <span class="o">=</span> <span class="s1">&#39;Z&#39;</span>
        <span class="n">z0</span><span class="o">.</span><span class="n">positive</span> <span class="o">=</span> <span class="s1">&#39;down&#39;</span>

        <span class="n">D</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;D&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,))</span>
        <span class="n">D</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;Orifice diameter&#39;</span>
        <span class="n">D</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;diameter&#39;</span>
        <span class="n">D</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;m&#39;</span>

        <span class="n">Vj</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;Vj&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,))</span>
        <span class="n">Vj</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;Discharge velocity&#39;</span>
        <span class="n">Vj</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;Vj&#39;</span>
        <span class="n">Vj</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;m&#39;</span>

        <span class="n">phi_0</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;phi_0&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,))</span>
        <span class="n">phi_0</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;Discharge vertical angle to horizontal&#39;</span>
        <span class="n">phi_0</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;phi_0&#39;</span>
        <span class="n">phi_0</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;rad&#39;</span>

        <span class="n">theta_0</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;theta_0&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,))</span>
        <span class="n">theta_0</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;Discharge horizontal angle to x-axis&#39;</span>
        <span class="n">theta_0</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;theta_0&#39;</span>
        <span class="n">theta_0</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;rad&#39;</span>

        <span class="n">Sj</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;Sj&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,))</span>
        <span class="n">Sj</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;Discharge salinity&#39;</span>
        <span class="n">Sj</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;Sj&#39;</span>
        <span class="n">Sj</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;psu&#39;</span>

        <span class="n">Tj</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;Tj&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,))</span>
        <span class="n">Tj</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;Discharge temperature&#39;</span>
        <span class="n">Tj</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;Tj&#39;</span>
        <span class="n">Tj</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;K&#39;</span>

        <span class="n">cj</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;cj&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,))</span>
        <span class="n">cj</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;Discharge tracer concentration&#39;</span>
        <span class="n">cj</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;cj&#39;</span>
        <span class="n">cj</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;nondimensional&#39;</span>

        <span class="n">Ta</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;Ta&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,))</span>
        <span class="n">Ta</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;ambient temperature at the release point&#39;</span>
        <span class="n">Ta</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;Ta&#39;</span>
        <span class="n">Ta</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;K&#39;</span>

        <span class="n">Sa</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;Sa&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,))</span>
        <span class="n">Sa</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;ambient salinity at the release point&#39;</span>
        <span class="n">Sa</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;Sa&#39;</span>
        <span class="n">Sa</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;psu&#39;</span>

        <span class="n">P</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;P&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,))</span>
        <span class="n">P</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;ambient pressure at the release point&#39;</span>
        <span class="n">P</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;P&#39;</span>
        <span class="n">P</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;Pa&#39;</span>

        <span class="c1"># Create variables for the simulation setup</span>
        <span class="n">track</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;track&#39;</span><span class="p">,</span> <span class="s1">&#39;i4&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,))</span>
        <span class="n">track</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;SBM Status (0: false, 1: true)&#39;</span>
        <span class="n">track</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;track&#39;</span>
        <span class="n">track</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;boolean&#39;</span>

        <span class="n">dt_max</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;dt_max&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,))</span>
        <span class="n">dt_max</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;Simulation maximum duration&#39;</span>
        <span class="n">dt_max</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;dt_max&#39;</span>
        <span class="n">dt_max</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;s&#39;</span>

        <span class="n">sd_max</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;sd_max&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;params&#39;</span><span class="p">,))</span>
        <span class="n">sd_max</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;Maximum distance along centerline s/D&#39;</span>
        <span class="n">sd_max</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;sd_max&#39;</span>
        <span class="n">sd_max</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;nondimensional&#39;</span>

        <span class="c1"># Create a variable for the independent variable</span>
        <span class="n">t</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;t&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;t&#39;</span><span class="p">,</span> <span class="s1">&#39;profile&#39;</span><span class="p">,))</span>
        <span class="n">t</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;time along the plume centerline&#39;</span>
        <span class="n">t</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;time&#39;</span>
        <span class="n">t</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;s&#39;</span>
        <span class="n">t</span><span class="o">.</span><span class="n">axis</span> <span class="o">=</span> <span class="s1">&#39;T&#39;</span>
        <span class="n">t</span><span class="o">.</span><span class="n">n_times</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">t</span><span class="p">)</span>

        <span class="c1"># Create a variable for the model state space</span>
        <span class="n">q</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">createVariable</span><span class="p">(</span><span class="s1">&#39;q&#39;</span><span class="p">,</span> <span class="s1">&#39;f8&#39;</span><span class="p">,</span> <span class="p">(</span><span class="s1">&#39;t&#39;</span><span class="p">,</span> <span class="s1">&#39;ns&#39;</span><span class="p">,))</span>
        <span class="n">q</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="s1">&#39;Lagranian plume model state space&#39;</span>
        <span class="n">q</span><span class="o">.</span><span class="n">standard_name</span> <span class="o">=</span> <span class="s1">&#39;q&#39;</span>
        <span class="n">q</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="s1">&#39;variable&#39;</span>

        <span class="c1"># Store the model initial conditions</span>
        <span class="n">x0</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">y0</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
        <span class="n">z0</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
        <span class="n">D</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">D</span>
        <span class="n">Vj</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Vj</span>
        <span class="n">phi_0</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">phi_0</span>
        <span class="n">theta_0</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">theta_0</span>
        <span class="n">Sj</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Sj</span>
        <span class="n">Tj</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span>
        <span class="n">cj</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cj</span>
        <span class="n">Ta</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">Sa</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">P</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="o">.</span><span class="n">get_values</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">[</span><span class="mi">2</span><span class="p">]),</span>
            <span class="p">[</span><span class="s1">&#39;temperature&#39;</span><span class="p">,</span> <span class="s1">&#39;salinity&#39;</span><span class="p">,</span> <span class="s1">&#39;pressure&#39;</span><span class="p">])</span>

        <span class="c1"># Store the model setup</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">track</span><span class="p">:</span>
            <span class="n">track</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">track</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="n">dt_max</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dt_max</span>
        <span class="n">sd_max</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sd_max</span>

        <span class="c1"># Save the dispersed phase particles</span>
        <span class="n">dispersed_phases</span><span class="o">.</span><span class="n">save_particle_to_nc_file</span><span class="p">(</span><span class="n">nc</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">chem_names</span><span class="p">,</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">K_T0</span><span class="p">)</span>

        <span class="c1"># Save the tracked particles if they exist</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">)):</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">farfield</span><span class="p">:</span>
                <span class="n">fname_sbm</span> <span class="o">=</span> <span class="n">fname</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;.nc&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="si">%3.3d</span><span class="s1">.nc&#39;</span> <span class="o">%</span> <span class="n">i</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">sbm</span><span class="o">.</span><span class="n">save_sim</span><span class="p">(</span><span class="n">fname_sbm</span><span class="p">,</span> <span class="n">profile_path</span><span class="p">,</span>
                    <span class="n">profile_info</span><span class="p">)</span>

        <span class="c1"># Store the plume simulation solution</span>
        <span class="n">t</span><span class="p">[:,</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">t</span><span class="p">[:]</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">nc</span><span class="o">.</span><span class="n">dimensions</span><span class="p">[</span><span class="s1">&#39;ns&#39;</span><span class="p">])):</span>
            <span class="n">q</span><span class="p">[:,</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">q</span><span class="p">[:,</span><span class="n">i</span><span class="p">]</span>

        <span class="c1"># Store any single bubble model simulations</span>


        <span class="c1"># Close the netCDF dataset</span>
        <span class="n">nc</span><span class="o">.</span><span class="n">close</span><span class="p">()</span></div>

<div class="viewcode-block" id="Model.save_txt"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.Model.save_txt.html#bent_plume_model.Model.save_txt">[docs]</a>    <span class="k">def</span> <span class="nf">save_txt</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">base_name</span><span class="p">,</span> <span class="n">profile_path</span><span class="p">,</span> <span class="n">profile_info</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Save the state space in ascii text format for exporting</span>

<span class="sd">        Save the state space (dependent and independent variables) in an</span>
<span class="sd">        ascii text file for exporting to other programs (e.g., Matlab).</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        base_name : str</span>
<span class="sd">            Base file name for the output file.  This method will append the</span>
<span class="sd">            .txt file extension to the data output and write a second file</span>
<span class="sd">            with the header information called base_name_header.txt.  If the</span>
<span class="sd">            particles that left the plume were tracked in the farfield, it</span>
<span class="sd">            will also save the trajectory of those particles as</span>
<span class="sd">            base_name_nnn.txt (output data) and base_name_nnn_header.txt</span>
<span class="sd">            (header data for far field data).</span>
<span class="sd">        profile_path : str</span>
<span class="sd">            String stating the file path to the ambient profile data relative</span>
<span class="sd">            to the directory where `fname` will be saved.</span>
<span class="sd">        profile_info : str</span>
<span class="sd">            Single line of text describing the ambient profile data.</span>

<span class="sd">        See Also</span>
<span class="sd">        --------</span>
<span class="sd">        save_sim, load_sim, stratified_plume_model.Model.save_txt,</span>
<span class="sd">        single_bubble_model.Model.save_txt</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        The output will be organized in columns, with each column as follows:</span>

<span class="sd">            0   : time (s)</span>
<span class="sd">            1-n : state space</span>

<span class="sd">        The header to the output file will give the extact organization of</span>
<span class="sd">        each column of the output data.</span>

<span class="sd">        These output files are written using the `numpy.savetxt` method.</span>

<span class="sd">        Note, also, that this only saves the state space solution, and the</span>
<span class="sd">        data saved by this function is inadequate to rebuild the `Model`</span>
<span class="sd">        object by reloading a saved solution.  To have seamless saving and</span>
<span class="sd">        loading of `Model` objects, use the `save_sim` and `load_sim`</span>
<span class="sd">        commands.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;No simulation results to store...&#39;</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Saved nothing to text file.</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
            <span class="k">return</span>

        <span class="c1"># Create the header string that contains the column descriptions</span>
        <span class="c1"># for the Lagrangian plume state space</span>
        <span class="n">p_list</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;Lagrangian Plume Model ASCII Output File </span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">]</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;Created: &#39;</span> <span class="o">+</span> <span class="n">datetime</span><span class="o">.</span><span class="n">today</span><span class="p">()</span><span class="o">.</span><span class="n">isoformat</span><span class="p">(</span><span class="s1">&#39; &#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;Simulation based on CTD data in:</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">profile_path</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">profile_info</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;Column Descriptions:</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    0: time (s)</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    1: mass (kg)</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    2: salinity (psu)</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    3: heat (J)</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    4: x-direction momentum (kg m/s)</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    5: y-direction momentum (kg m/s)</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    6: z-direction momentum (kg m/s)</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    7: relative thickness h/V (s)</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    8: x-coordinate (m)</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    9: y-coordinate (m)</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    10: z-coordinate (m)</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    11: distance along plume centerline (m)</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
        <span class="n">idx</span> <span class="o">=</span> <span class="mi">11</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">)):</span>
            <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">m0</span><span class="p">)):</span>
                <span class="n">idx</span> <span class="o">+=</span> <span class="mi">1</span>
                <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                    <span class="s1">&#39;    </span><span class="si">%d</span><span class="s1">: Total mass flux of </span><span class="si">%s</span><span class="s1"> in particle </span><span class="si">%d</span><span class="s1"> (kg/s)</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span>
                    <span class="p">(</span><span class="n">idx</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">composition</span><span class="p">[</span><span class="n">j</span><span class="p">],</span> <span class="n">i</span><span class="p">))</span>
            <span class="n">idx</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    </span><span class="si">%d</span><span class="s1">: Total heat flux of particle </span><span class="si">%d</span><span class="s1"> (J/s)</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span>
                          <span class="p">(</span><span class="n">idx</span><span class="p">,</span> <span class="n">i</span><span class="p">))</span>
            <span class="n">idx</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    </span><span class="si">%d</span><span class="s1">: Time since release of particle </span><span class="si">%d</span><span class="s1"> (s)</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span>
                          <span class="p">(</span><span class="n">idx</span><span class="p">,</span> <span class="n">i</span><span class="p">))</span>
            <span class="n">idx</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    </span><span class="si">%d</span><span class="s1">: Lambda coordinate of particle </span><span class="si">%d</span><span class="s1"> (m)</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span>
                          <span class="p">(</span><span class="n">idx</span><span class="p">,</span> <span class="n">i</span><span class="p">))</span>
            <span class="n">idx</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    </span><span class="si">%d</span><span class="s1">: Eta coordinate of particle </span><span class="si">%d</span><span class="s1"> (m)</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span>
                          <span class="p">(</span><span class="n">idx</span><span class="p">,</span> <span class="n">i</span><span class="p">))</span>
            <span class="n">idx</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    </span><span class="si">%d</span><span class="s1">: Csi coordinate of particle </span><span class="si">%d</span><span class="s1"> (m)</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span>
                          <span class="p">(</span><span class="n">idx</span><span class="p">,</span> <span class="n">i</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">chem_names</span><span class="p">)):</span>
            <span class="n">idx</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    </span><span class="si">%d</span><span class="s1">: Mass of dissolved </span><span class="si">%s</span><span class="s1"> (kg)</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span>
                          <span class="p">(</span><span class="n">idx</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">chem_names</span><span class="p">[</span><span class="n">i</span><span class="p">]))</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tracers</span><span class="p">)):</span>
            <span class="n">idx</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="n">p_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;    </span><span class="si">%d</span><span class="s1">: Mass of </span><span class="si">%s</span><span class="s1"> in (kg)</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span>
                          <span class="p">(</span><span class="n">idx</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">tracers</span><span class="p">[</span><span class="n">i</span><span class="p">]))</span>
        <span class="n">header</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p_list</span><span class="p">)</span>

        <span class="c1"># Assemble and write the state space data</span>
        <span class="n">data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">hstack</span><span class="p">((</span><span class="n">np</span><span class="o">.</span><span class="n">atleast_2d</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">t</span><span class="p">)</span><span class="o">.</span><span class="n">transpose</span><span class="p">(),</span> <span class="bp">self</span><span class="o">.</span><span class="n">q</span><span class="p">))</span>
        <span class="n">np</span><span class="o">.</span><span class="n">savetxt</span><span class="p">(</span><span class="n">base_name</span> <span class="o">+</span> <span class="s1">&#39;.txt&#39;</span><span class="p">,</span> <span class="n">data</span><span class="p">)</span>
        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">base_name</span> <span class="o">+</span> <span class="s1">&#39;_header.txt&#39;</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">dat_file</span><span class="p">:</span>
            <span class="n">dat_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">header</span><span class="p">)</span>

        <span class="c1"># Save the tracked particles if they exist</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">)):</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">farfield</span><span class="p">:</span>
                <span class="n">fname_sbm</span> <span class="o">=</span> <span class="n">base_name</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="si">%3.3d</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">i</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">sbm</span><span class="o">.</span><span class="n">save_txt</span><span class="p">(</span><span class="n">fname_sbm</span><span class="p">,</span> <span class="n">profile_path</span><span class="p">,</span>
                    <span class="n">profile_info</span><span class="p">)</span></div>

<div class="viewcode-block" id="Model.load_sim"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.Model.load_sim.html#bent_plume_model.Model.load_sim">[docs]</a>    <span class="k">def</span> <span class="nf">load_sim</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fname</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Load in a saved simulation result file for post-processing</span>

<span class="sd">        Load in a saved simulation result file and rebuild the `Model`</span>
<span class="sd">        object attributes.  The input file must be in netCDF4-classic data</span>
<span class="sd">        format.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fname : str</span>
<span class="sd">            File name of the file to read</span>

<span class="sd">        See Also</span>
<span class="sd">        --------</span>
<span class="sd">        save_sim</span>

<span class="sd">        Notes</span>
<span class="sd">        -----</span>
<span class="sd">        This method will attempt to load the ambient profile data from the</span>
<span class="sd">        `profile_path` attribute of the `fname` netCDF file.  If the load</span>
<span class="sd">        fails, a warning will be reported to the terminal, but the other</span>
<span class="sd">        steps of loading the `Model` object attributes will be performed.</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Open the netCDF dataset object containing the simulation results</span>
        <span class="n">nc</span> <span class="o">=</span> <span class="n">Dataset</span><span class="p">(</span><span class="n">fname</span><span class="p">)</span>

        <span class="c1"># Try to get the profile data</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">profile</span> <span class="o">=</span> <span class="n">model_share</span><span class="o">.</span><span class="n">profile_from_model_savefile</span><span class="p">(</span><span class="n">nc</span><span class="p">,</span> <span class="n">fname</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">profile</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">p</span> <span class="o">=</span> <span class="n">ModelParams</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">got_profile</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">p</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">got_profile</span> <span class="o">=</span> <span class="kc">False</span>

        <span class="c1"># Get the release location of the plume</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">X</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;x0&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;y0&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">X</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;z0&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>

        <span class="c1"># Create the Particle objects</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">chem_names</span> <span class="o">=</span> \
            <span class="n">dispersed_phases</span><span class="o">.</span><span class="n">load_particle_from_nc_file</span><span class="p">(</span><span class="n">nc</span><span class="p">)</span>

        <span class="c1"># Extract the remaining model constants</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">D</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;D&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Vj</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;Vj&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">phi_0</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;phi_0&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">theta_0</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;theta_0&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Sj</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;Sj&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Tj</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;Tj&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cj</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;cj&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
        <span class="k">if</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;track&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">track</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">track</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dt_max</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;dt_max&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sd_max</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;sd_max&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>

        <span class="c1"># Compute the dimensions of the arrayed data</span>
        <span class="n">ns</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">nc</span><span class="o">.</span><span class="n">dimensions</span><span class="p">[</span><span class="s1">&#39;ns&#39;</span><span class="p">])</span>
        <span class="n">nt</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;t&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">n_times</span>

        <span class="c1"># Extract the arrayed data</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">tracers</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">tracers</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">K_T0</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">K_T</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span>
                              <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">))])</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">nt</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">t</span><span class="p">[:]</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;t&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">:</span><span class="n">nt</span><span class="p">,</span><span class="mi">0</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">q</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="n">nt</span><span class="p">,</span> <span class="n">ns</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">ns</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">q</span><span class="p">[:,</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">nc</span><span class="o">.</span><span class="n">variables</span><span class="p">[</span><span class="s1">&#39;q&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">:</span><span class="n">nt</span><span class="p">,</span><span class="n">i</span><span class="p">]</span>

        <span class="c1"># Create the local Lagrangian plume element</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">q_local</span> <span class="o">=</span> <span class="n">LagElement</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">t</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">q</span><span class="p">[</span><span class="mi">0</span><span class="p">,:],</span> <span class="bp">self</span><span class="o">.</span><span class="n">D</span><span class="p">,</span>
                       <span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">p</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">tracers</span><span class="p">,</span>
                       <span class="bp">self</span><span class="o">.</span><span class="n">chem_names</span><span class="p">)</span>

        <span class="c1"># Load in any farfield tracking results</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">)):</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">farfield</span><span class="p">:</span>
                <span class="n">fname_sbm</span> <span class="o">=</span> <span class="n">fname</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;.nc&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="si">%3.3d</span><span class="s1">.nc&#39;</span> <span class="o">%</span> <span class="n">i</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">sbm</span> <span class="o">=</span> \
                    <span class="n">single_bubble_model</span><span class="o">.</span><span class="n">Model</span><span class="p">(</span><span class="n">simfile</span><span class="o">=</span><span class="n">fname_sbm</span><span class="p">)</span>

        <span class="c1"># Close the netCDF dataset</span>
        <span class="n">nc</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="o">=</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="Model.plot_state_space"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.Model.plot_state_space.html#bent_plume_model.Model.plot_state_space">[docs]</a>    <span class="k">def</span> <span class="nf">plot_state_space</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fig</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the simulation state space</span>

<span class="sd">        Plot the standard set of state space variables used to evaluate</span>
<span class="sd">        the quality of the model solution</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fig : int</span>
<span class="sd">            Number of the figure window in which to draw the plot</span>

<span class="sd">        See Also</span>
<span class="sd">        --------</span>
<span class="sd">        plot_all_variables</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">matplotlib</span> <span class="k">as</span> <span class="nn">mpl</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;No simulation results available to plot...&#39;</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Plotting nothing.</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
            <span class="k">return</span>

        <span class="c1"># Plot the results</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Plotting the state space...&#39;</span><span class="p">)</span>
        <span class="n">plot_state_space</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">t</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">q</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">q_local</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">p</span><span class="p">,</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">,</span> <span class="n">fig</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Done.</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span></div>

<div class="viewcode-block" id="Model.plot_all_variables"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.Model.plot_all_variables.html#bent_plume_model.Model.plot_all_variables">[docs]</a>    <span class="k">def</span> <span class="nf">plot_all_variables</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fig</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot a comprehensive suite of simulation results</span>

<span class="sd">        Generate a comprehensive suite of graphs showing the state and</span>
<span class="sd">        derived variables along with ambient profile data in order to</span>
<span class="sd">        view the model output for detailed analysis.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        fig : int</span>
<span class="sd">            Number of the figure window in which to draw the plot</span>

<span class="sd">        See Also</span>
<span class="sd">        --------</span>
<span class="sd">        plot_state_space</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">matplotlib</span> <span class="k">as</span> <span class="nn">mpl</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;No simulation results available to plot...&#39;</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Plotting nothing.</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
            <span class="k">return</span>

        <span class="c1"># Plot the results</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Plotting the full variable suite...&#39;</span><span class="p">)</span>
        <span class="n">plot_all_variables</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">t</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">q</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">q_local</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">profile</span><span class="p">,</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">p</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">particles</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">track</span><span class="p">,</span> <span class="n">fig</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Done.</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span></div></div>


<span class="c1"># ----------------------------------------------------------------------------</span>
<span class="c1"># Model Parameters objects</span>
<span class="c1"># ----------------------------------------------------------------------------</span>

<div class="viewcode-block" id="ModelParams"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.ModelParams.html#bent_plume_model.ModelParams">[docs]</a><span class="k">class</span> <span class="nc">ModelParams</span><span class="p">(</span><span class="n">single_bubble_model</span><span class="o">.</span><span class="n">ModelParams</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Fixed model parameters for the bent plume model</span>

<span class="sd">    This class stores the set of model parameters that should not be adjusted</span>
<span class="sd">    by the user and that are needed by the bent plume model.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    profile : `ambient.Profile` object</span>
<span class="sd">        The ambient CTD object used by the simulation.</span>

<span class="sd">    Attributes</span>
<span class="sd">    ----------</span>
<span class="sd">    alpha_j : float</span>
<span class="sd">        Jet shear entrainment coefficient.</span>
<span class="sd">    alpha_Fr : float</span>
<span class="sd">        Plume entrainment coefficient in Froude-number expression.</span>
<span class="sd">    gamma : float</span>
<span class="sd">        Momentum amplification factor</span>
<span class="sd">    Fr_0 : float</span>
<span class="sd">        Initial plume Froude number for the Wuest et al. (1992) multiphase</span>
<span class="sd">        plume initial conditions</span>
<span class="sd">    rho_r : float</span>
<span class="sd">        Reference density (kg/m^3) evaluated at mid-depth of the water body.</span>
<span class="sd">    g : float</span>
<span class="sd">        Acceleration of gravity (m/s^2)</span>
<span class="sd">    Ru : float</span>
<span class="sd">        Ideal gas constant (J/mol/K)</span>

<span class="sd">    Notes</span>
<span class="sd">    -----</span>
<span class="sd">    This object inherits all of the parameters of the</span>
<span class="sd">    `single_bubble_model.ModelParams` object.</span>

<span class="sd">    &quot;&quot;&quot;</span>
<div class="viewcode-block" id="ModelParams.__init__"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.ModelParams.html#bent_plume_model.ModelParams.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">profile</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">ModelParams</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">profile</span><span class="p">)</span>

        <span class="c1"># Set the model parameters to the values in Jirka (2004)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">alpha_j</span> <span class="o">=</span> <span class="mf">0.057</span>  <span class="c1"># Changed from 0.055 on 11/20/2018</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">alpha_Fr</span> <span class="o">=</span> <span class="mf">0.544</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">gamma</span> <span class="o">=</span> <span class="mf">1.10</span>

        <span class="c1"># Set some of the multiphase plume model parameters</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Fr_0</span> <span class="o">=</span> <span class="mf">1.6</span></div></div>


<span class="c1"># ----------------------------------------------------------------------------</span>
<span class="c1"># Particle object that handles tracking and exiting the plume</span>
<span class="c1"># ----------------------------------------------------------------------------</span>

<div class="viewcode-block" id="Particle"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.Particle.html#bent_plume_model.Particle">[docs]</a><span class="k">class</span> <span class="nc">Particle</span><span class="p">(</span><span class="n">dispersed_phases</span><span class="o">.</span><span class="n">PlumeParticle</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Special model properties for tracking inside a Lagrangian plume object</span>

<span class="sd">    This new `Particle` class is needed to allow dispersed phase particles to</span>
<span class="sd">    be tracked within the Lagrangian plume element during the solution and</span>
<span class="sd">    to exit the plume at the right time.</span>

<span class="sd">    This object inherits the `dispersed_phases.PlumeParticle` object and</span>
<span class="sd">    adds functionality for three-dimensional positioning and particle</span>
<span class="sd">    tracking.  All behavior not associated with tracking is identical to</span>
<span class="sd">    that in the `dispersed_phases.PlumeParticle` object.  Moreover, this</span>
<span class="sd">    object can be used in a `stratified_plume_model.Model` simulation.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    x : float</span>
<span class="sd">        Initial position of the particle in the x-direction (m)</span>
<span class="sd">    y : float</span>
<span class="sd">        Initial position of the particle in the y-direction (m)</span>
<span class="sd">    z : float</span>
<span class="sd">        Initial position of the particle in the z-direction (m)</span>
<span class="sd">    dbm_particle : `dbm.FluidParticle` or `dbm.InsolubleParticle` object</span>
<span class="sd">        Object describing the particle properties and behavior</span>
<span class="sd">    m0 : ndarray</span>
<span class="sd">        Initial masses of one particle for the components of the</span>
<span class="sd">        `dbm_particle` object (kg)</span>
<span class="sd">    T0 : float</span>
<span class="sd">        Initial temperature of the of `dbm` particle object (K)</span>
<span class="sd">    nb0 : float</span>
<span class="sd">        Initial number flux of particles at the release (#/s)</span>
<span class="sd">    lambda_1 : float</span>
<span class="sd">        spreading rate of the dispersed phase in a plume (--)</span>
<span class="sd">    P : float</span>
<span class="sd">        Local pressure (Pa)</span>
<span class="sd">    Sa : float</span>
<span class="sd">        Local salinity surrounding the particle (psu)</span>
<span class="sd">    Ta : float</span>
<span class="sd">        Local temperature surrounding the particle (K)</span>
<span class="sd">    K : float, default = 1.</span>
<span class="sd">        Mass transfer reduction factor (--).</span>
<span class="sd">    K_T : float, default = 1.</span>
<span class="sd">        Heat transfer reduction factor (--).</span>
<span class="sd">    fdis : float, default = 1.e-6</span>
<span class="sd">        Fraction (--) of the initial mass of each component of the mixture</span>
<span class="sd">        when that component should be considered totally dissolved.</span>
<span class="sd">    t_hyd : float, default = 0.</span>
<span class="sd">        Hydrate film formation time (s).  Mass transfer is computed by clean</span>
<span class="sd">        bubble methods for t less than t_hyd and by dirty bubble methods</span>
<span class="sd">        thereafter.  The default behavior is to assume the particle is dirty</span>
<span class="sd">        or hydrate covered from the release.</span>
<span class="sd">    lag_time : bool, default = True.</span>
<span class="sd">        Flag that indicates whether (True) or not (False) to use the</span>
<span class="sd">        biodegradation lag times data.</span>

<span class="sd">    Attributes</span>
<span class="sd">    ----------</span>
<span class="sd">    particle : `dbm.FluidParticle` or `dbm.InsolubleParticle` object</span>
<span class="sd">        Stores the `dbm_particle` object passed to at creation.</span>
<span class="sd">    composition : str list</span>
<span class="sd">        Copy of the `composition` attribute of the `dbm_particle` object.</span>
<span class="sd">    m0 : ndarray</span>
<span class="sd">        Initial masses (kg) of one particle for the particle components</span>
<span class="sd">    T0 : float</span>
<span class="sd">        Initial temperature (K) of the particle</span>
<span class="sd">    cp : float</span>
<span class="sd">        Heat capacity at constant pressure (J/(kg K)) of the particle.</span>
<span class="sd">    K : float</span>
<span class="sd">        Mass transfer reduction factor (--)</span>
<span class="sd">    K_T : float</span>
<span class="sd">        Heat transfer reduction factor (--)</span>
<span class="sd">    fdis : float</span>
<span class="sd">        Fraction of initial mass remaining as total dissolution (--)</span>
<span class="sd">    diss_indices : ndarray bool</span>
<span class="sd">        Indices of m0 that are non-zero.</span>
<span class="sd">    t_hyd : float</span>
<span class="sd">        Formation time for a hydrate skin (s)</span>
<span class="sd">    nb0 : float</span>
<span class="sd">        Initial number flux of particles at the release (#/s)</span>
<span class="sd">    nbe : float</span>
<span class="sd">        Number of particles associated with a Lagrangian element (#).  This</span>
<span class="sd">        number with the mass per particle sets the total mass of particles</span>
<span class="sd">        inside the Lagrangian element at any given time.  This value is set</span>
<span class="sd">        by `lmp.bent_plume_ic`.</span>
<span class="sd">    lambda_1 : float</span>
<span class="sd">        Spreading rate of the dispersed phase in a plume (--)</span>
<span class="sd">    m : ndarray</span>
<span class="sd">        Masses of the particle components for a single particle (kg)</span>
<span class="sd">    us : float</span>
<span class="sd">        Slip velocity (m/s)</span>
<span class="sd">    rho_p : float</span>
<span class="sd">        Particle density (kg/m^3)</span>
<span class="sd">    A : float</span>
<span class="sd">        Particle surface area (m^2)</span>
<span class="sd">    Cs : ndarray</span>
<span class="sd">        Solubility of each dissolving component in the particle (kg/m^3)</span>
<span class="sd">    beta : ndarray</span>
<span class="sd">        Mass transfer coefficients (m/s)</span>
<span class="sd">    beta_T : float</span>
<span class="sd">        Heat transfer coefficient (m/s)</span>
<span class="sd">    T : float</span>
<span class="sd">        Temperature of the particle (K)</span>
<span class="sd">    integrate : bool</span>
<span class="sd">        Flag indicating whether or not the particle is still inside the plume,</span>
<span class="sd">        where its trajectory should continue to be integrated.</span>
<span class="sd">    t : float</span>
<span class="sd">        Current time since the particle was released (s)</span>
<span class="sd">    x : float</span>
<span class="sd">        Current position of the particle in the x-direction (m)</span>
<span class="sd">    y : float</span>
<span class="sd">        Current position of the particle in the y-direction (m)</span>
<span class="sd">    z : float</span>
<span class="sd">        Current position of the particle in the z-direction (m)</span>
<span class="sd">    p_fac : float</span>
<span class="sd">        Buoyant force reduction factor due to a reduced buoyancy as the</span>
<span class="sd">        particle moves to the edge of the plume (--)</span>
<span class="sd">    b_local : float</span>
<span class="sd">        Width of the bent plume model at the location where the particle</span>
<span class="sd">        exited the plume.</span>
<span class="sd">    sbm : `single_bubble_model.Model` object</span>
<span class="sd">        Model object for tracking the particle outside the plume</span>


<span class="sd">    See Also</span>
<span class="sd">    --------</span>
<span class="sd">    dispersed_phases.SingleParticle, dispersed_phases.PlumeParticle</span>

<span class="sd">    &quot;&quot;&quot;</span>
<div class="viewcode-block" id="Particle.__init__"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.Particle.html#bent_plume_model.Particle.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">,</span> <span class="n">dbm_particle</span><span class="p">,</span> <span class="n">m0</span><span class="p">,</span> <span class="n">T0</span><span class="p">,</span> <span class="n">nb0</span><span class="p">,</span> <span class="n">lambda_1</span><span class="p">,</span>
                 <span class="n">P</span><span class="p">,</span> <span class="n">Sa</span><span class="p">,</span> <span class="n">Ta</span><span class="p">,</span> <span class="n">K</span><span class="o">=</span><span class="mf">1.</span><span class="p">,</span> <span class="n">K_T</span><span class="o">=</span><span class="mf">1.</span><span class="p">,</span> <span class="n">fdis</span><span class="o">=</span><span class="mf">1.e-6</span><span class="p">,</span> <span class="n">t_hyd</span><span class="o">=</span><span class="mf">0.</span><span class="p">,</span>
                 <span class="n">lag_time</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">Particle</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">dbm_particle</span><span class="p">,</span> <span class="n">m0</span><span class="p">,</span> <span class="n">T0</span><span class="p">,</span> <span class="n">nb0</span><span class="p">,</span> <span class="n">lambda_1</span><span class="p">,</span>
                                       <span class="n">P</span><span class="p">,</span> <span class="n">Sa</span><span class="p">,</span> <span class="n">Ta</span><span class="p">,</span> <span class="n">K</span><span class="p">,</span> <span class="n">K_T</span><span class="p">,</span> <span class="n">fdis</span><span class="p">,</span> <span class="n">t_hyd</span><span class="p">,</span>
                                       <span class="n">lag_time</span><span class="p">)</span>

        <span class="c1"># Particles start inside the plume and should be integrated</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">integrate</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sim_stored</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">farfield</span> <span class="o">=</span> <span class="kc">False</span>

        <span class="c1"># Store the initial particle locations</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">t</span> <span class="o">=</span> <span class="mf">0.</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">x</span> <span class="o">=</span> <span class="n">x</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">y</span> <span class="o">=</span> <span class="n">y</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">z</span> <span class="o">=</span> <span class="n">z</span>

        <span class="c1"># Update the particle with its current properties</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">m0</span><span class="p">,</span> <span class="n">T0</span><span class="p">,</span> <span class="n">P</span><span class="p">,</span> <span class="n">Sa</span><span class="p">,</span> <span class="n">Ta</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">t</span><span class="p">)</span></div>

<div class="viewcode-block" id="Particle.track"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.Particle.track.html#bent_plume_model.Particle.track">[docs]</a>    <span class="k">def</span> <span class="nf">track</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">t_p</span><span class="p">,</span> <span class="n">X_cl</span><span class="p">,</span> <span class="n">X_p</span><span class="p">,</span> <span class="n">q_local</span><span class="p">,</span> <span class="n">Ainv</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Track the particle in the Lagragian plume model</span>

<span class="sd">        Track the location of the particle within a Lagrangian plume model</span>
<span class="sd">        element and stop the integration when the particle exits the plume.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        t_p : float</span>
<span class="sd">            Time since the particle was released (s)</span>
<span class="sd">        X_cl : ndarray</span>
<span class="sd">            Array of Cartesian coordinates (x,y,z) for the plume centerline</span>
<span class="sd">            (m).</span>
<span class="sd">        X_p : ndarray</span>
<span class="sd">            Array of local plume coordinates (l,n,m) for the current</span>
<span class="sd">            particle position (m)().  This method converts these coordinates,</span>
<span class="sd">            which are solved by the bent plume model state space solution, to</span>
<span class="sd">            Cartesian coordinates.</span>
<span class="sd">        q_local : `LagElement` object</span>
<span class="sd">            Object that translates the bent plume model state space `t` and</span>
<span class="sd">            `q` into the comprehensive list of derived variables.</span>
<span class="sd">        Ainv : ndarray, default = None</span>
<span class="sd">            Coordinate transformation matrix from the local plume coordinates</span>
<span class="sd">            (l,n,m) to Cartesian coordinates (x,y,z).  If `Ainv` is known, it</span>
<span class="sd">            can be passed to this function; otherwise, this function can</span>
<span class="sd">            solve for `Ainv` using q_local.</span>

<span class="sd">        Returns</span>
<span class="sd">        -------</span>
<span class="sd">        xp : ndarray</span>
<span class="sd">            Array of Cartesian coordinates (x,y,z) for the current particle</span>
<span class="sd">            position (m).</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">integrate</span><span class="p">:</span>
            <span class="c1"># Compute the transformation matrix from local plume coordinates</span>
            <span class="c1"># (l,n,m) to Cartesian coordinates (x,y,z) if needed</span>
            <span class="k">if</span> <span class="n">Ainv</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="n">A</span> <span class="o">=</span> <span class="n">lmp</span><span class="o">.</span><span class="n">local_coords</span><span class="p">(</span><span class="n">q_local</span><span class="p">,</span> <span class="n">q_local</span><span class="p">,</span> <span class="mf">0.</span><span class="p">)</span>
                <span class="n">Ainv</span> <span class="o">=</span> <span class="n">inv</span><span class="p">(</span><span class="n">A</span><span class="p">)</span>

            <span class="c1"># Update the particle age</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">t</span> <span class="o">=</span> <span class="n">t_p</span>
            <span class="n">tp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">t</span>

            <span class="c1"># Get the particle position</span>
            <span class="n">xp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">Ainv</span><span class="p">,</span> <span class="n">X_p</span><span class="p">)</span> <span class="o">+</span> <span class="n">X_cl</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">x</span> <span class="o">=</span> <span class="n">xp</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">y</span> <span class="o">=</span> <span class="n">xp</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">z</span> <span class="o">=</span> <span class="n">xp</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>

            <span class="c1"># Compute the particle offset from the plume centerline</span>
            <span class="n">lp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">X_p</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">X_p</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">X_p</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>

            <span class="c1"># Compute the buoyant force reduction factor</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">p_fac</span> <span class="o">=</span> <span class="p">(</span><span class="n">q_local</span><span class="o">.</span><span class="n">b</span> <span class="o">-</span> <span class="n">lp</span><span class="p">)</span><span class="o">**</span><span class="mi">4</span> <span class="o">/</span> <span class="n">q_local</span><span class="o">.</span><span class="n">b</span><span class="o">**</span><span class="mi">4</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">p_fac</span> <span class="o">&lt;</span> <span class="mf">0.</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">p_fac</span> <span class="o">=</span> <span class="mf">0.</span>

            <span class="c1"># Check if the particle exited the plume</span>
            <span class="k">if</span> <span class="n">lp</span> <span class="o">&gt;</span> <span class="n">q_local</span><span class="o">.</span><span class="n">b</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">p_fac</span> <span class="o">=</span> <span class="mf">0.</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">b_local</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">b</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="c1"># Return the time and position when the particle exited the plume</span>
            <span class="n">tp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">te</span>
            <span class="n">xp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">xe</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">ye</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">ze</span><span class="p">])</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">p_fac</span> <span class="o">=</span> <span class="mf">0.</span>

        <span class="c1"># Return the particle position as a matrix</span>
        <span class="k">return</span> <span class="p">(</span><span class="n">tp</span><span class="p">,</span> <span class="n">xp</span><span class="p">)</span></div>

<div class="viewcode-block" id="Particle.outside"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.Particle.outside.html#bent_plume_model.Particle.outside">[docs]</a>    <span class="k">def</span> <span class="nf">outside</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">Ta</span><span class="p">,</span> <span class="n">Sa</span><span class="p">,</span> <span class="n">Pa</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Remove the effect of particles if they are outside the plume</span>

<span class="sd">        Sets all of the particle properties that generate forces or</span>
<span class="sd">        dissolution to zero effect if the particle is outside the plume.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        Ta : float</span>
<span class="sd">            Local temperature surrounding the particle (K)</span>
<span class="sd">        Sa : float</span>
<span class="sd">            Local salinity surrounding the particle (psu)</span>
<span class="sd">        Pa : float</span>
<span class="sd">            Local pressure (Pa)</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">us</span> <span class="o">=</span> <span class="mf">0.</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">rho_p</span> <span class="o">=</span> <span class="n">seawater</span><span class="o">.</span><span class="n">density</span><span class="p">(</span><span class="n">Ta</span><span class="p">,</span> <span class="n">Sa</span><span class="p">,</span> <span class="n">Pa</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">A</span> <span class="o">=</span> <span class="mf">0.</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Cs</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">composition</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">beta</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">composition</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">beta_T</span> <span class="o">=</span> <span class="mf">0.</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">T</span> <span class="o">=</span> <span class="n">Ta</span></div>

<div class="viewcode-block" id="Particle.run_sbm"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.Particle.run_sbm.html#bent_plume_model.Particle.run_sbm">[docs]</a>    <span class="k">def</span> <span class="nf">run_sbm</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">profile</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Run the `single_bubble_model` to track particles outside the plume</span>

<span class="sd">        Continues the simulation of the particle is outside of the plume using</span>
<span class="sd">        the `single_bubble_model`.  The object containing the simulation</span>
<span class="sd">        and simulation results will be added to the attributes of this</span>
<span class="sd">        Particle object.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        profile : `ambient.Profile` object</span>
<span class="sd">            Ambient CTD data for the model simulation</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Create the simulation object</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sbm</span> <span class="o">=</span> <span class="n">single_bubble_model</span><span class="o">.</span><span class="n">Model</span><span class="p">(</span><span class="n">profile</span><span class="p">)</span>

        <span class="c1"># Create the inputs to the sbm.simulate method</span>
        <span class="n">X0</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">y</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">z</span><span class="p">])</span>
        <span class="n">Ta</span><span class="p">,</span> <span class="n">Sa</span><span class="p">,</span> <span class="n">P</span> <span class="o">=</span> <span class="n">profile</span><span class="o">.</span><span class="n">get_values</span><span class="p">(</span><span class="n">X0</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;temperature&#39;</span><span class="p">,</span> <span class="s1">&#39;salinity&#39;</span><span class="p">,</span>
                    <span class="s1">&#39;pressure&#39;</span><span class="p">])</span>
        <span class="n">de</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">diameter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">m</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="n">P</span><span class="p">,</span> <span class="n">Sa</span><span class="p">,</span> <span class="n">Ta</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">particle</span><span class="o">.</span><span class="n">issoluble</span><span class="p">:</span>
            <span class="n">yk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">particle</span><span class="o">.</span><span class="n">mol_frac</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">m</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">yk</span> <span class="o">=</span> <span class="mf">1.</span>

        <span class="c1"># Run the simulation</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sbm</span><span class="o">.</span><span class="n">simulate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">particle</span><span class="p">,</span> <span class="n">X0</span><span class="p">,</span> <span class="n">de</span><span class="p">,</span> <span class="n">yk</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">K</span><span class="p">,</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">K_T</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">fdis</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">t_hyd</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">lag_time</span><span class="p">,</span> <span class="n">delta_t</span><span class="o">=</span><span class="mf">100000.</span><span class="p">)</span>

        <span class="c1"># Set flag indicating that far-field solution was computed</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">farfield</span> <span class="o">=</span> <span class="kc">True</span></div></div>


<span class="c1"># ----------------------------------------------------------------------------</span>
<span class="c1"># Object to translate the state space into all the derived variables</span>
<span class="c1"># ----------------------------------------------------------------------------</span>

<div class="viewcode-block" id="LagElement"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.LagElement.html#bent_plume_model.LagElement">[docs]</a><span class="k">class</span> <span class="nc">LagElement</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Manages the Lagragian plume element state space and derived variables</span>

<span class="sd">    Translates the state space variables for a Lagrangian plume element into</span>
<span class="sd">    its individual parts and derived quantitites.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    t0 : float</span>
<span class="sd">        Initial time of the simulation (s)</span>
<span class="sd">    q0 : ndarray</span>
<span class="sd">        Initial values of the simulation state space, q</span>
<span class="sd">    D : float</span>
<span class="sd">        Diameter for the equivalent circular cross-section of the release (m)</span>
<span class="sd">    profile : `ambient.Profile`</span>
<span class="sd">        Ambient CTD data</span>
<span class="sd">    p : `ModelParams`</span>
<span class="sd">        Container for the fixed model parameters</span>
<span class="sd">    particles : list of `Particle` objects</span>
<span class="sd">        List of `Particle` objects describing each dispersed phase in the</span>
<span class="sd">        simulation</span>
<span class="sd">    tracers : string list</span>
<span class="sd">        List of passive tracers in the discharge.  These can be chemicals</span>
<span class="sd">        present in the ambient `profile` data, and if so, entrainment of these</span>
<span class="sd">        chemicals will change the concentrations computed for these tracers.</span>
<span class="sd">        However, none of these concentrations are used in the dissolution of</span>
<span class="sd">        the dispersed phase.  Hence, `tracers` should not contain any</span>
<span class="sd">        chemicals present in the dispersed phase particles.</span>
<span class="sd">    chem_names : string list</span>
<span class="sd">        List of chemical parameters to track for the dissolution.  Only the</span>
<span class="sd">        parameters in this list will be used to set background concentration</span>
<span class="sd">        for the dissolution, and the concentrations of these parameters are</span>
<span class="sd">        computed separately from those listed in `tracers` or inputed from</span>
<span class="sd">        the discharge through `cj`.</span>

<span class="sd">    Attributes</span>
<span class="sd">    ----------</span>
<span class="sd">    t0 : float</span>
<span class="sd">        Initial time of the simulation (s)</span>
<span class="sd">    q0 : ndarray</span>
<span class="sd">        Initial values of the simulation state space, q</span>
<span class="sd">    D : float</span>
<span class="sd">        Diameter for the equivalent circular cross-section of the release (m)</span>
<span class="sd">    tracers : string list</span>
<span class="sd">        List of passive tracers in the discharge.  These can be chemicals</span>
<span class="sd">        present in the ambient `profile` data, and if so, entrainment of these</span>
<span class="sd">        chemicals will change the concentrations computed for these tracers.</span>
<span class="sd">        However, none of these concentrations are used in the dissolution of</span>
<span class="sd">        the dispersed phase.  Hence, `tracers` should not contain any</span>
<span class="sd">        chemicals present in the dispersed phase particles.</span>
<span class="sd">    chem_names : string list</span>
<span class="sd">        List of chemical parameters to track for the dissolution.  Only the</span>
<span class="sd">        parameters in this list will be used to set background concentration</span>
<span class="sd">        for the dissolution, and the concentrations of these parameters are</span>
<span class="sd">        computed separately from those listed in `tracers` or inputed from</span>
<span class="sd">        the discharge through `cj`.</span>
<span class="sd">    len : int</span>
<span class="sd">        Number of variables in the state space q (--)</span>
<span class="sd">    ntracers : int</span>
<span class="sd">        Number of passive chemical tracers (--)</span>
<span class="sd">    nchems : int</span>
<span class="sd">        Number of chemicals tracked for dissolution of the dispersed phase</span>
<span class="sd">        particles (--)</span>
<span class="sd">    np : int</span>
<span class="sd">        Number of dispersed phase particles (--)</span>
<span class="sd">    t : float</span>
<span class="sd">        Independent variable for the current time (s)</span>
<span class="sd">    q : ndarray</span>
<span class="sd">        Dependent variable for the current state space</span>
<span class="sd">    M : float</span>
<span class="sd">        Mass of the Lagrangian element (kg)</span>
<span class="sd">    Se : float</span>
<span class="sd">        Salt in the Lagrangian element (psu kg)</span>
<span class="sd">    He : float</span>
<span class="sd">        Heat of the Lagrangian element (J)</span>
<span class="sd">    Jx : float</span>
<span class="sd">        Dynamic momentum of the Lagrangian element in the x-direction</span>
<span class="sd">        (kg m/s)</span>
<span class="sd">    Jy : float</span>
<span class="sd">        Dynamic momentum of the Lagrangian element in the y-direction</span>
<span class="sd">        (kg m/s)</span>
<span class="sd">    Jz : float</span>
<span class="sd">        Dynamic momentum of the Lagrangian element in the z-direction</span>
<span class="sd">        (kg m/s)</span>
<span class="sd">    H : float</span>
<span class="sd">        Relative thickness of the Lagrangian element h/V (s)</span>
<span class="sd">    x : float</span>
<span class="sd">        Current x-position of the Lagrangian element (m)</span>
<span class="sd">    y : float</span>
<span class="sd">        Current y-position of the Lagrangian element (m)</span>
<span class="sd">    z : float</span>
<span class="sd">        Current z-position of the Lagrangian element (m)</span>
<span class="sd">    s : float</span>
<span class="sd">        Current s-position along the centerline of the plume for the</span>
<span class="sd">        Lagrangian element (m)</span>
<span class="sd">    M_p : dict of ndarrays</span>
<span class="sd">        For integer key: the total mass fluxes (kg/s) of each component in a</span>
<span class="sd">        particle.</span>
<span class="sd">    H_p : ndarray</span>
<span class="sd">        Total heat flux for each particle (J/s)</span>
<span class="sd">    t_p : ndarray</span>
<span class="sd">        Time since release for each particle (s)</span>
<span class="sd">    X_p : ndarray</span>
<span class="sd">        Position of each particle in local plume coordinates (l,n,m) (m).</span>
<span class="sd">    cpe : ndarray</span>
<span class="sd">        Masses of the chemical components involved in dissolution (kg)</span>
<span class="sd">    cte : ndarray</span>
<span class="sd">        Masses of the passive tracers in the plume (concentration kg)</span>
<span class="sd">    Pa : float</span>
<span class="sd">        Ambient pressure at the current element location (Pa)</span>
<span class="sd">    Ta : float</span>
<span class="sd">        Ambient temperature at the current element location (K)</span>
<span class="sd">    Sa : float</span>
<span class="sd">        Ambient salinity at the current element location (psu)</span>
<span class="sd">    ua : float</span>
<span class="sd">        Crossflow velocity in the x-direction at the current element location</span>
<span class="sd">        (m/s)</span>
<span class="sd">    ca_chems : ndarray</span>
<span class="sd">        Ambient concentration of the chemical components involved in</span>
<span class="sd">        dissolution at the current element location (kg/m^3)</span>
<span class="sd">    ca_tracers :</span>
<span class="sd">        Ambient concentration of the passive tracers in the plume at the</span>
<span class="sd">        current element location (concentration)</span>
<span class="sd">    rho_a : float</span>
<span class="sd">        Ambient density at the current element location (kg/m^3)</span>
<span class="sd">    S : float</span>
<span class="sd">        Salinity of the Lagrangian element (psu)</span>
<span class="sd">    T : float</span>
<span class="sd">        Temperature of the Lagrangian element (T)</span>
<span class="sd">    c_chems :</span>
<span class="sd">        Concentration of the chemical components involved in dissolution for</span>
<span class="sd">        the Lagrangian element (kg/m^3)</span>
<span class="sd">    c_tracers :</span>
<span class="sd">        Concentration of the passive tracers in the Lagrangian element</span>
<span class="sd">        (concentration)</span>
<span class="sd">    u : float</span>
<span class="sd">        Velocity in the x-direction of the Lagrangian element (m/s)</span>
<span class="sd">    v : float</span>
<span class="sd">        Velocity in the y-direction of the Lagrangian element (m/s)</span>
<span class="sd">    w : float</span>
<span class="sd">        Velocity in the z-direction of the Lagrangian element (m/s)</span>
<span class="sd">    hvel : float</span>
<span class="sd">        Velocity in the horizontal plane for the Lagrangian element (m/s)</span>
<span class="sd">    V : float</span>
<span class="sd">        Velocity in the s-direction of the Lagrangian element (m/s)</span>
<span class="sd">    h : float</span>
<span class="sd">        Current thickness of the Lagrangian element (m)</span>
<span class="sd">    rho : float</span>
<span class="sd">        Density of the entrained seawater in the Lagrangian element (kg/m^3)</span>
<span class="sd">    b : float</span>
<span class="sd">        Half-width of the Lagrangian element (m)</span>
<span class="sd">    sin_p : float</span>
<span class="sd">        The sine of the angle phi (--)</span>
<span class="sd">    cos_p : float</span>
<span class="sd">        The cosine of the angle phi (--)</span>
<span class="sd">    sin_t : float</span>
<span class="sd">        The sine of the angle theta (--)</span>
<span class="sd">    cos_t : float</span>
<span class="sd">        The cosine of the angle theta (--)</span>
<span class="sd">    phi : float</span>
<span class="sd">        The vertical angle from horizontal of the current plume trajectory</span>
<span class="sd">        (rad in range +/- pi/2).  Since z is positive down (depth), phi =</span>
<span class="sd">        pi/2 point down and -pi/2 points up.</span>
<span class="sd">    theta : float</span>
<span class="sd">        The lateral angle in the horizontal plane from the x-axis to the</span>
<span class="sd">        current plume trajectory (rad in range 0 to 2 pi)</span>
<span class="sd">    mp : ndarray</span>
<span class="sd">        Masses of each of the dispersed phase particles in the `particles`</span>
<span class="sd">        variable</span>
<span class="sd">    fb : ndarray</span>
<span class="sd">        Buoyant force for each of the dispersed phase particles in the</span>
<span class="sd">        `particles` variable as density difference (kg/m^3)</span>
<span class="sd">    x_p : ndarray</span>
<span class="sd">    Mp : float</span>
<span class="sd">        Total mass of dispersed phases in the Lagrangian element (kg)</span>
<span class="sd">    Fb : float</span>
<span class="sd">        Total buoyant force as density difference of the dispersed phases in</span>
<span class="sd">        the Lagrangian element (kg/m^3)</span>

<span class="sd">    &quot;&quot;&quot;</span>
<div class="viewcode-block" id="LagElement.__init__"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.LagElement.html#bent_plume_model.LagElement.__init__">[docs]</a>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">t0</span><span class="p">,</span> <span class="n">q0</span><span class="p">,</span> <span class="n">D</span><span class="p">,</span> <span class="n">profile</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">particles</span><span class="p">,</span> <span class="n">tracers</span><span class="p">,</span>
                 <span class="n">chem_names</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">(</span><span class="n">LagElement</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>

        <span class="c1"># Store the inputs to stay with the Lagrangian element</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">t0</span> <span class="o">=</span> <span class="n">t0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">q0</span> <span class="o">=</span> <span class="n">q0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">D</span> <span class="o">=</span> <span class="n">D</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">tracers</span> <span class="o">=</span> <span class="n">tracers</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">chem_names</span> <span class="o">=</span> <span class="n">chem_names</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">len</span> <span class="o">=</span> <span class="n">q0</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">ntracers</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tracers</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">nchems</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">chem_names</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">np</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">particles</span><span class="p">)</span>

        <span class="c1"># Extract the state variables and compute the derived quantities</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">t0</span><span class="p">,</span> <span class="n">q0</span><span class="p">,</span> <span class="n">profile</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">particles</span><span class="p">)</span></div>

<div class="viewcode-block" id="LagElement.update"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.LagElement.update.html#bent_plume_model.LagElement.update">[docs]</a>    <span class="k">def</span> <span class="nf">update</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">q</span><span class="p">,</span> <span class="n">profile</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">particles</span><span class="o">=</span><span class="p">[]):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Update the `LagElement` object with the current local conditions</span>

<span class="sd">        Extract the state variables and compute the derived quantities given</span>
<span class="sd">        the current local conditions.</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------</span>
<span class="sd">        t : float</span>
<span class="sd">            Current time of the simulation (s)</span>
<span class="sd">        q : ndarray</span>
<span class="sd">            Current values of the simulation state space, q</span>
<span class="sd">        profile : `ambient.Profile`</span>
<span class="sd">            Ambient CTD data</span>
<span class="sd">        p : `ModelParams`</span>
<span class="sd">            Container for the fixed model parameters</span>
<span class="sd">        particles : list of `Particle` objects</span>
<span class="sd">            List of `Particle` objects describing each dispersed phase in the</span>
<span class="sd">            simulation</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Save the current state space</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">t</span> <span class="o">=</span> <span class="n">t</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">q</span> <span class="o">=</span> <span class="n">q</span>

        <span class="c1"># Extract the state-space variables from q</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">M</span> <span class="o">=</span> <span class="n">q</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Se</span> <span class="o">=</span> <span class="n">q</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">He</span> <span class="o">=</span> <span class="n">q</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Jx</span> <span class="o">=</span> <span class="n">q</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Jy</span> <span class="o">=</span> <span class="n">q</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Jz</span> <span class="o">=</span> <span class="n">q</span><span class="p">[</span><span class="mi">5</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">H</span> <span class="o">=</span> <span class="n">q</span><span class="p">[</span><span class="mi">6</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">x</span> <span class="o">=</span> <span class="n">q</span><span class="p">[</span><span class="mi">7</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">y</span> <span class="o">=</span> <span class="n">q</span><span class="p">[</span><span class="mi">8</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">z</span> <span class="o">=</span> <span class="n">q</span><span class="p">[</span><span class="mi">9</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">s</span> <span class="o">=</span> <span class="n">q</span><span class="p">[</span><span class="mi">10</span><span class="p">]</span>
        <span class="n">idx</span> <span class="o">=</span> <span class="mi">11</span>
        <span class="n">M_p</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="n">H_p</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">t_p</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">X_p</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">np</span><span class="p">):</span>
            <span class="n">M_p</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q</span><span class="p">[</span><span class="n">idx</span><span class="p">:</span><span class="n">idx</span> <span class="o">+</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">particle</span><span class="o">.</span><span class="n">nc</span><span class="p">]</span>
            <span class="n">idx</span> <span class="o">+=</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">particle</span><span class="o">.</span><span class="n">nc</span>
            <span class="n">H_p</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">q</span><span class="p">[</span><span class="n">idx</span><span class="p">:</span><span class="n">idx</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span>
            <span class="n">idx</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="n">t_p</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">q</span><span class="p">[</span><span class="n">idx</span><span class="p">:</span><span class="n">idx</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span>
            <span class="n">idx</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="n">X_p</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">q</span><span class="p">[</span><span class="n">idx</span><span class="p">:</span><span class="n">idx</span> <span class="o">+</span> <span class="mi">3</span><span class="p">])</span>
            <span class="n">idx</span> <span class="o">+=</span> <span class="mi">3</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">M_p</span> <span class="o">=</span> <span class="n">M_p</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">H_p</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">H_p</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">t_p</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">t_p</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">X_p</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">X_p</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cpe</span> <span class="o">=</span> <span class="n">q</span><span class="p">[</span><span class="n">idx</span><span class="p">:</span><span class="n">idx</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">nchems</span><span class="p">]</span>
        <span class="n">idx</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">nchems</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ntracers</span> <span class="o">&gt;=</span> <span class="mi">1</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">cte</span> <span class="o">=</span> <span class="n">q</span><span class="p">[</span><span class="n">idx</span><span class="p">:]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">cte</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([])</span>

        <span class="c1"># Get the local ambient conditions</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Pa</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Ta</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Sa</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">ua</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">va</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">wa</span> <span class="o">=</span> \
            <span class="n">profile</span><span class="o">.</span><span class="n">get_values</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">z</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;pressure&#39;</span><span class="p">,</span> <span class="s1">&#39;temperature&#39;</span><span class="p">,</span>
            <span class="s1">&#39;salinity&#39;</span><span class="p">,</span> <span class="s1">&#39;ua&#39;</span><span class="p">,</span> <span class="s1">&#39;va&#39;</span><span class="p">,</span> <span class="s1">&#39;wa&#39;</span><span class="p">])</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">ca_chems</span> <span class="o">=</span> <span class="n">profile</span><span class="o">.</span><span class="n">get_values</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">z</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">chem_names</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">ca_tracers</span> <span class="o">=</span> <span class="n">profile</span><span class="o">.</span><span class="n">get_values</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">z</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">tracers</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">rho_a</span> <span class="o">=</span> <span class="n">seawater</span><span class="o">.</span><span class="n">density</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">Ta</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Sa</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Pa</span><span class="p">)</span>

        <span class="c1"># Compute the derived quantities</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">S</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Se</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">M</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">T</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">He</span> <span class="o">/</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">M</span> <span class="o">*</span> <span class="n">seawater</span><span class="o">.</span><span class="n">cp</span><span class="p">())</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">rho</span> <span class="o">=</span> <span class="n">seawater</span><span class="o">.</span><span class="n">density</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">T</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">S</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Pa</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">c_chems</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cpe</span> <span class="o">/</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">M</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">rho</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">c_tracers</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cte</span> <span class="o">/</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">M</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">rho</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">u</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Jx</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">M</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">v</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Jy</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">M</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">w</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Jz</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">M</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">hvel</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">u</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">v</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">V</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">hvel</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">w</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">h</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">H</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">V</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">b</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">M</span> <span class="o">/</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">rho</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">h</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sin_p</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">w</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">V</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cos_p</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">hvel</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">V</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">hvel</span> <span class="o">==</span> <span class="mf">0.</span><span class="p">:</span>
            <span class="c1"># if hvel = 0, flow is purely along z; let theta = 0</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">sin_t</span> <span class="o">=</span> <span class="mf">0.</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">cos_t</span> <span class="o">=</span> <span class="mf">1.</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">sin_t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">v</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">hvel</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">cos_t</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">u</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">hvel</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">phi</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arctan2</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">w</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">hvel</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">theta</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arctan2</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">v</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">u</span><span class="p">)</span>

        <span class="c1"># Compute the transformation matrix from the local plume coordinates</span>
        <span class="c1"># (l,n,m) to Cartesian coordinates (x,y,z)</span>
        <span class="n">Ainv</span> <span class="o">=</span> <span class="n">inv</span><span class="p">(</span><span class="n">lmp</span><span class="o">.</span><span class="n">local_coords</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="p">,</span> <span class="mf">0.</span><span class="p">))</span>

        <span class="c1"># Get the particle characteristics</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">np</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">fb</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">np</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">x_p</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="bp">self</span><span class="o">.</span><span class="n">np</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>

        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">np</span><span class="p">):</span>
            <span class="c1"># If this is a post-processing call, update the status of the</span>
            <span class="c1"># integration flag</span>
            <span class="k">if</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">sim_stored</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">X_p</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">0</span><span class="p">]):</span>
                    <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">integrate</span> <span class="o">=</span> <span class="kc">False</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">integrate</span> <span class="o">=</span> <span class="kc">True</span>

            <span class="c1"># Update the particles with their current properties</span>
            <span class="n">m_p</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">M_p</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">/</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">nbe</span>
            <span class="n">T_p</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">H_p</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">/</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">M_p</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> <span class="o">*</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">cp</span><span class="p">)</span>
            <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">m_p</span><span class="p">,</span> <span class="n">T_p</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">Pa</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">S</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">T</span><span class="p">,</span>
                                <span class="bp">self</span><span class="o">.</span><span class="n">t_p</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>

            <span class="c1"># Store biodegradation rates to use with dissolved phase</span>
            <span class="k">if</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">particle</span><span class="o">.</span><span class="n">issoluble</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">k_bio</span> <span class="o">=</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">k_bio</span>

            <span class="c1"># Track the particle in the plume</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">t_p</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">x_p</span><span class="p">[</span><span class="n">i</span><span class="p">,:]</span> <span class="o">=</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">track</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">t_p</span><span class="p">[</span><span class="n">i</span><span class="p">],</span>
                            <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">y</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">z</span><span class="p">]),</span>
                            <span class="bp">self</span><span class="o">.</span><span class="n">X_p</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="bp">self</span><span class="p">,</span> <span class="n">Ainv</span><span class="p">)</span>

            <span class="c1"># Get the mass of particles following this Lagrangian element</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">mp</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">m_p</span><span class="p">)</span> <span class="o">*</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">nbe</span>

            <span class="c1"># Compute the buoyant force coming from this set of particles</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">fb</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">rho</span> <span class="o">/</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">rho_p</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">mp</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">*</span> \
                         <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">rho_a</span> <span class="o">-</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">rho_p</span><span class="p">)</span> <span class="o">*</span> \
                         <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">p_fac</span>

            <span class="c1"># Force the particle mass and bubble force to zero if the bubble</span>
            <span class="c1"># has dissolved</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">rho</span> <span class="o">==</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">rho_p</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">mp</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">fb</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.</span>

        <span class="c1"># Compute the net particle mass and buoyant force</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Fb</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">fb</span><span class="p">)</span></div></div>


<span class="c1"># ----------------------------------------------------------------------------</span>
<span class="c1"># Functions to plot output from the simulations</span>
<span class="c1"># ----------------------------------------------------------------------------</span>

<div class="viewcode-block" id="plot_state_space"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.plot_state_space.html#bent_plume_model.plot_state_space">[docs]</a><span class="k">def</span> <span class="nf">plot_state_space</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">q</span><span class="p">,</span> <span class="n">q_local</span><span class="p">,</span> <span class="n">profile</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">particles</span><span class="p">,</span> <span class="n">fig</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Plot the Lagrangian model state space</span>

<span class="sd">    Plot the standard set of state space variables used to evaluate the</span>
<span class="sd">    quality of the model solution</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    t : ndarray</span>
<span class="sd">        Array of times computed in the solution (s)</span>
<span class="sd">    q : ndarray</span>
<span class="sd">        Array of state space values computed in the solution</span>
<span class="sd">    q_local : `LagElement` object</span>
<span class="sd">        Object that translates the `Model` state space `t` and `q` into the</span>
<span class="sd">        comprehensive list of derived variables.</span>
<span class="sd">    profile : `ambient.Profile`</span>
<span class="sd">        Ambient CTD data</span>
<span class="sd">    p : `ModelParams`</span>
<span class="sd">        Container for the fixed model parameters</span>
<span class="sd">    particles : list of `Particle` objects</span>
<span class="sd">        List of `Particle` objects describing each dispersed phase in the</span>
<span class="sd">        simulation</span>
<span class="sd">    fig : int</span>
<span class="sd">        Number of the figure window in which to draw the plot</span>

<span class="sd">    Notes</span>
<span class="sd">    -----</span>
<span class="sd">    Plots the trajectory of the jet centerline, the trajectory of the</span>
<span class="sd">    simulated particles, and the Lagrangian element mass.</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="kn">import</span> <span class="nn">matplotlib</span> <span class="k">as</span> <span class="nn">mpl</span>
    <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>

    <span class="c1"># Extract the trajectory variables</span>
    <span class="n">x</span> <span class="o">=</span> <span class="n">q</span><span class="p">[:,</span><span class="mi">7</span><span class="p">]</span>
    <span class="n">y</span> <span class="o">=</span> <span class="n">q</span><span class="p">[:,</span><span class="mi">8</span><span class="p">]</span>
    <span class="n">z</span> <span class="o">=</span> <span class="n">q</span><span class="p">[:,</span><span class="mi">9</span><span class="p">]</span>
    <span class="n">s</span> <span class="o">=</span> <span class="n">q</span><span class="p">[:,</span><span class="mi">10</span><span class="p">]</span>
    <span class="n">M</span> <span class="o">=</span> <span class="n">q</span><span class="p">[:,</span><span class="mi">0</span><span class="p">]</span>

    <span class="c1"># Extract the particle positions from the q state space</span>
    <span class="n">xp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">),</span><span class="mi">3</span><span class="o">*</span><span class="nb">len</span><span class="p">(</span><span class="n">particles</span><span class="p">)))</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">)):</span>
        <span class="n">q_local</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">t</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">q</span><span class="p">[</span><span class="n">i</span><span class="p">,:],</span> <span class="n">profile</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">particles</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">particles</span><span class="p">)):</span>
            <span class="n">xp</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="o">*</span><span class="mi">3</span><span class="p">:</span><span class="n">j</span><span class="o">*</span><span class="mi">3</span><span class="o">+</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">x_p</span><span class="p">[</span><span class="n">j</span><span class="p">,:]</span>

    <span class="c1"># Plot the figure</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">fig</span><span class="p">)</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">clf</span><span class="p">()</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>

    <span class="c1"># x-z plane</span>
    <span class="n">ax1</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">221</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">particles</span><span class="p">)):</span>
        <span class="n">ax1</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">xp</span><span class="p">[:,</span><span class="n">i</span><span class="o">*</span><span class="mi">3</span><span class="p">],</span> <span class="n">xp</span><span class="p">[:,</span><span class="n">i</span><span class="o">*</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">2</span><span class="p">],</span> <span class="s1">&#39;.--&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;x (m)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;Depth (m)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.65&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="c1"># y-z plane</span>
    <span class="n">ax2</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">222</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">particles</span><span class="p">)):</span>
        <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">xp</span><span class="p">[:,</span><span class="n">i</span><span class="o">*</span><span class="mi">3</span><span class="o">+</span><span class="mi">1</span><span class="p">],</span> <span class="n">xp</span><span class="p">[:,</span><span class="n">i</span><span class="o">*</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">2</span><span class="p">],</span> <span class="s1">&#39;.--&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;y (m)&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;Depth (m)&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.65&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="c1"># x-y plane</span>
    <span class="n">ax3</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">223</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">particles</span><span class="p">)):</span>
        <span class="n">ax3</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">xp</span><span class="p">[:,</span><span class="n">i</span><span class="o">*</span><span class="mi">3</span><span class="p">],</span> <span class="n">xp</span><span class="p">[:,</span><span class="n">i</span><span class="o">*</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">1</span><span class="p">],</span> <span class="s1">&#39;.--&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;x (m)&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;y (m)&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.65&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="c1"># M-s plane</span>
    <span class="n">ax4</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">224</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">M</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;s (m)&#39;</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;M (kg)&#39;</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.65&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="n">plt</span><span class="o">.</span><span class="n">draw</span><span class="p">()</span></div>


<div class="viewcode-block" id="plot_all_variables"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.plot_all_variables.html#bent_plume_model.plot_all_variables">[docs]</a><span class="k">def</span> <span class="nf">plot_all_variables</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">q</span><span class="p">,</span> <span class="n">q_local</span><span class="p">,</span> <span class="n">profile</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">particles</span><span class="p">,</span>
                       <span class="n">tracked</span><span class="p">,</span> <span class="n">fig</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Plot a comprehensive suite of simulation results</span>

<span class="sd">    Generate a comprehensive suite of graphs showing the state and</span>
<span class="sd">    derived variables along with ambient profile data in order to</span>
<span class="sd">    view the model output for detailed analysis.</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    t : ndarray</span>
<span class="sd">        Array of times computed in the solution (s)</span>
<span class="sd">    q : ndarray</span>
<span class="sd">        Array of state space values computed in the solution</span>
<span class="sd">    q_local : `LagElement` object</span>
<span class="sd">        Object that translates the `Model` state space `t` and `q` into the</span>
<span class="sd">        comprehensive list of derived variables.</span>
<span class="sd">    profile : `ambient.Profile`</span>
<span class="sd">        Ambient CTD data</span>
<span class="sd">    p : `ModelParams`</span>
<span class="sd">        Container for the fixed model parameters</span>
<span class="sd">    particles : list of `Particle` objects</span>
<span class="sd">        List of `Particle` objects describing each dispersed phase in the</span>
<span class="sd">        simulation</span>
<span class="sd">    tracked : bool</span>
<span class="sd">        Flag indicating whether or not the `single_bubble_model` was run to</span>
<span class="sd">        track the particles.</span>
<span class="sd">    fig : int</span>
<span class="sd">        Number of the figure window in which to draw the plot</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c1"># Don&#39;t offset any of the axes</span>
    <span class="kn">import</span> <span class="nn">matplotlib</span> <span class="k">as</span> <span class="nn">mpl</span>
    <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>

    <span class="n">formatter</span> <span class="o">=</span> <span class="n">mpl</span><span class="o">.</span><span class="n">ticker</span><span class="o">.</span><span class="n">ScalarFormatter</span><span class="p">(</span><span class="n">useOffset</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>

    <span class="c1"># Create a second Lagrangian element in order to compute entrainment</span>
    <span class="n">q0_local</span> <span class="o">=</span> <span class="n">LagElement</span><span class="p">(</span><span class="n">t</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">q</span><span class="p">[</span><span class="mi">0</span><span class="p">,:],</span> <span class="n">q_local</span><span class="o">.</span><span class="n">D</span><span class="p">,</span> <span class="n">profile</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">particles</span><span class="p">,</span>
        <span class="n">q_local</span><span class="o">.</span><span class="n">tracers</span><span class="p">,</span> <span class="n">q_local</span><span class="o">.</span><span class="n">chem_names</span><span class="p">)</span>
    <span class="n">n_part</span> <span class="o">=</span> <span class="n">q0_local</span><span class="o">.</span><span class="n">np</span>
    <span class="n">pchems</span> <span class="o">=</span> <span class="mi">1</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">n_part</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">composition</span><span class="p">)</span> <span class="o">&gt;</span> <span class="n">pchems</span><span class="p">:</span>
            <span class="n">pchems</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">composition</span><span class="p">)</span>

    <span class="c1"># Store the derived variables</span>
    <span class="n">M</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">S</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">T</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">Mpf</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">),</span> <span class="n">n_part</span><span class="p">,</span> <span class="n">pchems</span><span class="p">))</span>
    <span class="n">Hp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">),</span> <span class="n">n_part</span><span class="p">))</span>
    <span class="n">Mp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">),</span> <span class="n">n_part</span><span class="p">))</span>
    <span class="n">Tp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">),</span> <span class="n">n_part</span><span class="p">))</span>
    <span class="n">xp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">),</span> <span class="mi">3</span><span class="o">*</span><span class="n">n_part</span><span class="p">))</span>
    <span class="n">u</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">v</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">w</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">V</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">h</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">x</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">y</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">z</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">s</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">rho</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">b</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">cos_p</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">sin_p</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">cos_t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">sin_t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">rho_a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">Sa</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">Ta</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">ua</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
    <span class="n">E</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">t</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>

    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">)):</span>
        <span class="k">if</span> <span class="n">i</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
            <span class="n">q0_local</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">t</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="n">q</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">,:],</span> <span class="n">profile</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">particles</span><span class="p">)</span>
        <span class="n">q_local</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">t</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">q</span><span class="p">[</span><span class="n">i</span><span class="p">,:],</span> <span class="n">profile</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">particles</span><span class="p">)</span>
        <span class="n">M</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">M</span>
        <span class="n">S</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">S</span>
        <span class="n">T</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">T</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">n_part</span><span class="p">):</span>
            <span class="n">Mpf</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">,</span><span class="mi">0</span><span class="p">:</span><span class="nb">len</span><span class="p">(</span><span class="n">q_local</span><span class="o">.</span><span class="n">M_p</span><span class="p">[</span><span class="n">j</span><span class="p">])]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">M_p</span><span class="p">[</span><span class="n">j</span><span class="p">][:]</span>
            <span class="n">Mp</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">particles</span><span class="p">[</span><span class="n">j</span><span class="p">]</span><span class="o">.</span><span class="n">m</span><span class="p">[:])</span>
            <span class="n">Tp</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">particles</span><span class="p">[</span><span class="n">j</span><span class="p">]</span><span class="o">.</span><span class="n">T</span>
            <span class="n">xp</span><span class="p">[</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="o">*</span><span class="mi">3</span><span class="p">:</span><span class="n">j</span><span class="o">*</span><span class="mi">3</span><span class="o">+</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">x_p</span><span class="p">[</span><span class="n">j</span><span class="p">,:]</span>
        <span class="n">Hp</span><span class="p">[</span><span class="n">i</span><span class="p">,:]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">H_p</span>
        <span class="n">u</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">u</span>
        <span class="n">v</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">v</span>
        <span class="n">w</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">w</span>
        <span class="n">V</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">V</span>
        <span class="n">h</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">h</span>
        <span class="n">x</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">x</span>
        <span class="n">y</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">y</span>
        <span class="n">z</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">z</span>
        <span class="n">s</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">s</span>
        <span class="n">rho</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">rho</span>
        <span class="n">b</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">b</span>
        <span class="n">cos_p</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">cos_p</span>
        <span class="n">sin_p</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">sin_p</span>
        <span class="n">cos_t</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">cos_t</span>
        <span class="n">sin_t</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">sin_t</span>
        <span class="n">rho_a</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">rho_a</span>
        <span class="n">Sa</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">Sa</span>
        <span class="n">Ta</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">Ta</span>
        <span class="n">ua</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">q_local</span><span class="o">.</span><span class="n">ua</span>
        <span class="n">E</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">lmp</span><span class="o">.</span><span class="n">entrainment</span><span class="p">(</span><span class="n">q0_local</span><span class="p">,</span> <span class="n">q_local</span><span class="p">,</span> <span class="n">p</span><span class="p">)</span>

    <span class="c1"># Compute the unit vector along the plume axis</span>
    <span class="n">Sz</span> <span class="o">=</span> <span class="n">sin_p</span>
    <span class="n">Sx</span> <span class="o">=</span> <span class="n">cos_p</span> <span class="o">*</span> <span class="n">cos_t</span>
    <span class="n">Sy</span> <span class="o">=</span> <span class="n">cos_p</span> <span class="o">*</span> <span class="n">sin_t</span>

    <span class="c1"># Plot cross-sections through the plume</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">fig</span><span class="p">)</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">clf</span><span class="p">()</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
    <span class="n">fig</span> <span class="o">+=</span> <span class="mi">1</span>

    <span class="n">ax1</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">221</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">z</span><span class="p">,</span> <span class="s1">&#39;b-&#39;</span><span class="p">)</span>
    <span class="p">[</span><span class="n">x1</span><span class="p">,</span> <span class="n">z1</span><span class="p">,</span> <span class="n">x2</span><span class="p">,</span> <span class="n">z2</span><span class="p">]</span> <span class="o">=</span> <span class="n">width_projection</span><span class="p">(</span><span class="n">Sx</span><span class="p">,</span> <span class="n">Sz</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">x1</span><span class="p">,</span> <span class="n">z</span> <span class="o">+</span> <span class="n">z1</span><span class="p">,</span> <span class="s1">&#39;b--&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">x2</span><span class="p">,</span> <span class="n">z</span> <span class="o">+</span> <span class="n">z2</span><span class="p">,</span> <span class="s1">&#39;b--&#39;</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">particles</span><span class="p">)):</span>
        <span class="n">ax1</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">z</span><span class="p">,</span> <span class="s1">&#39;o&#39;</span><span class="p">)</span>
        <span class="n">ax1</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">xp</span><span class="p">[:,</span><span class="n">i</span><span class="o">*</span><span class="mi">3</span><span class="p">],</span> <span class="n">xp</span><span class="p">[:,</span><span class="n">i</span><span class="o">*</span><span class="mi">3</span><span class="o">+</span><span class="mi">2</span><span class="p">],</span> <span class="s1">&#39;.--&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">tracked</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">integrate</span> <span class="ow">is</span> <span class="kc">False</span> <span class="ow">and</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">z</span> <span class="o">&gt;</span> <span class="mf">0.</span><span class="p">:</span>
                <span class="n">ax1</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">sbm</span><span class="o">.</span><span class="n">y</span><span class="p">[:,</span><span class="mi">0</span><span class="p">],</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">sbm</span><span class="o">.</span><span class="n">y</span><span class="p">[:,</span><span class="mi">2</span><span class="p">],</span>
                         <span class="s1">&#39;.:&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;x (m)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;z (m)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.5&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="n">ax2</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">222</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">,</span> <span class="s1">&#39;b-&#39;</span><span class="p">)</span>
    <span class="p">[</span><span class="n">y1</span><span class="p">,</span> <span class="n">z1</span><span class="p">,</span> <span class="n">y2</span><span class="p">,</span> <span class="n">z2</span><span class="p">]</span> <span class="o">=</span> <span class="n">width_projection</span><span class="p">(</span><span class="n">Sy</span><span class="p">,</span> <span class="n">Sz</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">y</span> <span class="o">+</span> <span class="n">y1</span><span class="p">,</span> <span class="n">z</span> <span class="o">+</span> <span class="n">z1</span><span class="p">,</span> <span class="s1">&#39;b--&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">y</span> <span class="o">+</span> <span class="n">y2</span><span class="p">,</span> <span class="n">z</span> <span class="o">+</span> <span class="n">z2</span><span class="p">,</span> <span class="s1">&#39;b--&#39;</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">particles</span><span class="p">)):</span>
        <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">y</span><span class="p">,</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">z</span><span class="p">,</span> <span class="s1">&#39;o&#39;</span><span class="p">)</span>
        <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">xp</span><span class="p">[:,</span><span class="n">i</span><span class="o">*</span><span class="mi">3</span><span class="o">+</span><span class="mi">1</span><span class="p">],</span> <span class="n">xp</span><span class="p">[:,</span><span class="n">i</span><span class="o">*</span><span class="mi">3</span><span class="o">+</span><span class="mi">2</span><span class="p">],</span> <span class="s1">&#39;.--&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">tracked</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">integrate</span> <span class="ow">is</span> <span class="kc">False</span> <span class="ow">and</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">z</span> <span class="o">&gt;</span> <span class="mf">0.</span><span class="p">:</span>
                <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">sbm</span><span class="o">.</span><span class="n">y</span><span class="p">[:,</span><span class="mi">1</span><span class="p">],</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">sbm</span><span class="o">.</span><span class="n">y</span><span class="p">[:,</span><span class="mi">2</span><span class="p">],</span>
                         <span class="s1">&#39;.:&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">invert_yaxis</span><span class="p">()</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;y (m)&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;z (m)&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.5&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="n">ax3</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">223</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="s1">&#39;b-&#39;</span><span class="p">)</span>
    <span class="p">[</span><span class="n">x1</span><span class="p">,</span> <span class="n">y1</span><span class="p">,</span> <span class="n">x2</span><span class="p">,</span> <span class="n">y2</span><span class="p">]</span> <span class="o">=</span> <span class="n">width_projection</span><span class="p">(</span><span class="n">Sx</span><span class="p">,</span> <span class="n">Sy</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">x1</span><span class="p">,</span> <span class="n">y</span> <span class="o">+</span> <span class="n">y1</span><span class="p">,</span> <span class="s1">&#39;b--&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span> <span class="o">+</span> <span class="n">x2</span><span class="p">,</span> <span class="n">y</span> <span class="o">+</span> <span class="n">y2</span><span class="p">,</span> <span class="s1">&#39;b--&#39;</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">particles</span><span class="p">)):</span>
        <span class="n">ax3</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">y</span><span class="p">,</span> <span class="s1">&#39;o&#39;</span><span class="p">)</span>
        <span class="n">ax3</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">xp</span><span class="p">[:,</span><span class="n">i</span><span class="o">*</span><span class="mi">3</span><span class="p">],</span> <span class="n">xp</span><span class="p">[:,</span><span class="n">i</span><span class="o">*</span><span class="mi">3</span><span class="o">+</span><span class="mi">1</span><span class="p">],</span> <span class="s1">&#39;.--&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">tracked</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">integrate</span> <span class="ow">is</span> <span class="kc">False</span> <span class="ow">and</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">z</span> <span class="o">&gt;</span> <span class="mf">0.</span><span class="p">:</span>
                <span class="n">ax3</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">sbm</span><span class="o">.</span><span class="n">y</span><span class="p">[:,</span><span class="mi">0</span><span class="p">],</span> <span class="n">particles</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">sbm</span><span class="o">.</span><span class="n">y</span><span class="p">[:,</span><span class="mi">1</span><span class="p">],</span>
                         <span class="s1">&#39;.:&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;x (m)&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;y (m)&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.5&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="n">ax4</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">224</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">shape</span><span class="p">),</span> <span class="s1">&#39;b-&#39;</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="s1">&#39;b--&#39;</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="o">-</span><span class="n">b</span><span class="p">,</span> <span class="s1">&#39;b--&#39;</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;s (m)&#39;</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;r (m)&#39;</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.5&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="n">plt</span><span class="o">.</span><span class="n">draw</span><span class="p">()</span>

    <span class="c1"># Plot the Lagrangian element height and entrainment rate</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">fig</span><span class="p">)</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">clf</span><span class="p">()</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
    <span class="n">fig</span> <span class="o">+=</span> <span class="mi">1</span>

    <span class="n">ax1</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">121</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">h</span><span class="p">,</span> <span class="s1">&#39;b-&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;s (m)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;h (m/s)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.5&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="n">ax2</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">122</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">E</span><span class="p">,</span> <span class="s1">&#39;b-&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;s (m)&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;E (kg/s)&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.5&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="n">plt</span><span class="o">.</span><span class="n">draw</span><span class="p">()</span>

    <span class="c1"># Plot the velocities along the plume centerline</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">fig</span><span class="p">)</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">clf</span><span class="p">()</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
    <span class="n">fig</span> <span class="o">+=</span> <span class="mi">1</span>

    <span class="n">ax1</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">221</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">u</span><span class="p">,</span> <span class="s1">&#39;b-&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">ua</span><span class="p">,</span> <span class="s1">&#39;g--&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;s (m)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;u (m/s)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.5&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="n">ax2</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">222</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">v</span><span class="p">,</span> <span class="s1">&#39;b-&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;s (m)&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;v (m/s)&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.5&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="n">ax3</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">223</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">w</span><span class="p">,</span> <span class="s1">&#39;b-&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;s (m)&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;w (m/s)&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.5&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="n">ax4</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">224</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">V</span><span class="p">,</span> <span class="s1">&#39;b-&#39;</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;s (m)&#39;</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;V (m/s)&#39;</span><span class="p">)</span>
    <span class="n">ax4</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.5&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="n">plt</span><span class="o">.</span><span class="n">draw</span><span class="p">()</span>

    <span class="c1"># Plot the salinity, temperature, and density in the plume</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">fig</span><span class="p">)</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">clf</span><span class="p">()</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">ticklabel_format</span><span class="p">(</span><span class="n">useOffset</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="s1">&#39;y&#39;</span><span class="p">)</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
    <span class="n">fig</span> <span class="o">+=</span> <span class="mi">1</span>

    <span class="n">ax1</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">221</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">yaxis</span><span class="o">.</span><span class="n">set_major_formatter</span><span class="p">(</span><span class="n">formatter</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">S</span><span class="p">,</span> <span class="s1">&#39;b-&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">Sa</span><span class="p">,</span> <span class="s1">&#39;g--&#39;</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">S</span><span class="p">)</span> <span class="o">-</span> <span class="n">np</span><span class="o">.</span><span class="n">min</span><span class="p">(</span><span class="n">S</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mf">1.e-6</span><span class="p">:</span>
        <span class="n">ax1</span><span class="o">.</span><span class="n">set_ylim</span><span class="p">([</span><span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">S</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;s (m)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;Salinity (psu)&#39;</span><span class="p">)</span>
    <span class="n">ax1</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.5&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="n">ax2</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">222</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">yaxis</span><span class="o">.</span><span class="n">set_major_formatter</span><span class="p">(</span><span class="n">formatter</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">T</span> <span class="o">-</span> <span class="mf">273.15</span><span class="p">,</span> <span class="s1">&#39;b-&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">Ta</span> <span class="o">-</span> <span class="mf">273.15</span><span class="p">,</span> <span class="s1">&#39;g--&#39;</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">T</span><span class="p">)</span> <span class="o">-</span> <span class="n">np</span><span class="o">.</span><span class="n">min</span><span class="p">(</span><span class="n">T</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mf">1.e-6</span><span class="p">:</span>
        <span class="n">ax2</span><span class="o">.</span><span class="n">set_ylim</span><span class="p">([</span><span class="n">T</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="mf">273.15</span> <span class="o">-</span> <span class="mf">1.</span><span class="p">,</span> <span class="n">T</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="mf">273.15</span> <span class="o">+</span> <span class="mf">1.</span><span class="p">])</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;s (m)&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;Temperature (deg C)&#39;</span><span class="p">)</span>
    <span class="n">ax2</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.5&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="n">ax3</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">223</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">yaxis</span><span class="o">.</span><span class="n">set_major_formatter</span><span class="p">(</span><span class="n">formatter</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">rho</span><span class="p">,</span> <span class="s1">&#39;b-&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">rho_a</span><span class="p">,</span> <span class="s1">&#39;g--&#39;</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">rho</span><span class="p">)</span> <span class="o">-</span> <span class="n">np</span><span class="o">.</span><span class="n">min</span><span class="p">(</span><span class="n">rho</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mf">1.e-6</span><span class="p">:</span>
        <span class="n">ax3</span><span class="o">.</span><span class="n">set_ylim</span><span class="p">([</span><span class="n">rho</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">rho</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;s (m)&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;Density (kg/m^3)&#39;</span><span class="p">)</span>
    <span class="n">ax3</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.5&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

    <span class="n">plt</span><span class="o">.</span><span class="n">draw</span><span class="p">()</span>

    <span class="c1"># Plot the particle mass and temperature</span>
    <span class="k">if</span> <span class="n">n_part</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">fig</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">clf</span><span class="p">()</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">ticklabel_format</span><span class="p">(</span><span class="n">useOffset</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="s1">&#39;y&#39;</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
        <span class="n">fig</span> <span class="o">+=</span> <span class="mi">1</span>

        <span class="n">ax1</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">121</span><span class="p">)</span>
        <span class="n">ax1</span><span class="o">.</span><span class="n">yaxis</span><span class="o">.</span><span class="n">set_major_formatter</span><span class="p">(</span><span class="n">formatter</span><span class="p">)</span>
        <span class="n">ax1</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">Mp</span> <span class="o">/</span> <span class="mf">1.e-6</span><span class="p">,</span> <span class="s1">&#39;b-&#39;</span><span class="p">)</span>
        <span class="n">ax1</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;s (m)&#39;</span><span class="p">)</span>
        <span class="n">ax1</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;m (mg)&#39;</span><span class="p">)</span>
        <span class="n">ax1</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.5&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

        <span class="n">ax2</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">122</span><span class="p">)</span>
        <span class="n">ax2</span><span class="o">.</span><span class="n">yaxis</span><span class="o">.</span><span class="n">set_major_formatter</span><span class="p">(</span><span class="n">formatter</span><span class="p">)</span>
        <span class="n">ax2</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">Tp</span> <span class="o">-</span> <span class="mf">273.15</span><span class="p">,</span> <span class="s1">&#39;b-&#39;</span><span class="p">)</span>
        <span class="n">ax2</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;s (m)&#39;</span><span class="p">)</span>
        <span class="n">ax2</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;Temperature (deg C)&#39;</span><span class="p">)</span>
        <span class="n">ax2</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">b</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">which</span><span class="o">=</span><span class="s1">&#39;major&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;0.5&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">draw</span><span class="p">()</span></div>


<div class="viewcode-block" id="width_projection"><a class="viewcode-back" href="../autodoc/bpm/bent_plume_model.width_projection.html#bent_plume_model.width_projection">[docs]</a><span class="k">def</span> <span class="nf">width_projection</span><span class="p">(</span><span class="n">Sx</span><span class="p">,</span> <span class="n">Sy</span><span class="p">,</span> <span class="n">b</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Find the location of the plume width in x, y, z space</span>

<span class="sd">    Converts the width b and plume orientation phi and theta into an</span>
<span class="sd">    (x, y, z) location of the plume edge.  This function provides a two-</span>
<span class="sd">    dimensional result given the unit vector along the plume centerline</span>
<span class="sd">    (Sx, Sy) along two dimensions in the (x, y, z) space</span>

<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    Sx : float</span>
<span class="sd">        Unit vector projection of the plume trajectory on one of the</span>
<span class="sd">        coordinate axes in (x, y, z) space.</span>
<span class="sd">    Sy : float</span>
<span class="sd">        Unit vector projection of the plume trajectory on another of the</span>
<span class="sd">        coordinate axes in (x, y, z) space.</span>
<span class="sd">    b : float</span>
<span class="sd">        Local plume width</span>

<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    x1 : float</span>
<span class="sd">        Plume edge for Sx projection to left of plume translation direction</span>
<span class="sd">    y1 : float</span>
<span class="sd">        Plume edge for Sy projection to left of plume translation direction</span>
<span class="sd">    x2 : float</span>
<span class="sd">        Plume edge for Sx projection to right of plume translation direction</span>
<span class="sd">    y1 : float</span>
<span class="sd">        Plume edge for Sy projection to right of plume translation direction</span>

<span class="sd">    Notes</span>
<span class="sd">    -----</span>
<span class="sd">    The values of S in the (x, y, z) sytem would be::</span>

<span class="sd">        Sz = sin ( phi )</span>
<span class="sd">        Sx = cos ( phi ) * cos ( theta )</span>
<span class="sd">        Sy = cos ( phi ) * sin ( theta )</span>

<span class="sd">    Any two of these coordinates of the unit vector can be provided to this</span>
<span class="sd">    function as input.</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c1"># Get the angle to the s-direction in the x-y plane</span>
    <span class="n">alpha</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arctan2</span><span class="p">(</span><span class="n">Sy</span><span class="p">,</span> <span class="n">Sx</span><span class="p">)</span>

    <span class="c1"># Get the coordinates of the plume edge to the right of the s-vector</span>
    <span class="c1"># moving with the plume</span>
    <span class="n">x1</span> <span class="o">=</span> <span class="n">b</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">cos</span><span class="p">(</span><span class="n">alpha</span> <span class="o">-</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span><span class="o">/</span><span class="mf">2.</span><span class="p">)</span>
    <span class="n">y1</span> <span class="o">=</span> <span class="n">b</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="n">alpha</span> <span class="o">-</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span><span class="o">/</span><span class="mf">2.</span><span class="p">)</span>

    <span class="c1"># Get the coordinates of the plume edge to the left of the s-vector</span>
    <span class="c1"># moving with the plume</span>
    <span class="n">x2</span> <span class="o">=</span> <span class="n">b</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">cos</span><span class="p">(</span><span class="n">alpha</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span><span class="o">/</span><span class="mf">2.</span><span class="p">)</span>
    <span class="n">y2</span> <span class="o">=</span> <span class="n">b</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="n">alpha</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span><span class="o">/</span><span class="mf">2.</span><span class="p">)</span>

    <span class="k">return</span> <span class="p">(</span><span class="n">x1</span><span class="p">,</span> <span class="n">y1</span><span class="p">,</span> <span class="n">x2</span><span class="p">,</span> <span class="n">y2</span><span class="p">)</span></div>

</pre></div>

          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">Texas A&M Oil spill / Outfall Calculator</a></h1>








<h3>Navigation</h3>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../user_manual.html">TAMOC User Manual</a></li>
<li class="toctree-l1"><a class="reference internal" href="../unit_tests.html">Unit Tests</a></li>
<li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../bugs.html">Reporting Bugs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../readme.html">Read Me File</a></li>
<li class="toctree-l1"><a class="reference internal" href="../release.html">Release Notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../license.html">License</a></li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="../index.html">Documentation overview</a><ul>
  <li><a href="index.html">Module code</a><ul>
  </ul></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2020, Scott A. Socolofsky.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.4</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
    </div>

    

    
  </body>
</html>